NodeJs: 🔗 https://nodejs.org/en/
- Clone this repo
git clone https://github.com/Aleydon/NodeJs-Template.git
- Install NPM packages
npm install or yarn install
- Run this project
npm run dev or yarn dev
- Jest for automated testing. 🔗 https://jestjs.io/
- Eslint + Prettier for code standardization and formatting. 🔗 https://eslint.org/ + https://prettier.io/
- Typescript for typing. 🔗 https://www.typescriptlang.org/
- HuskyJs for automatically lint your commit messages, code, and run tests upon committing or pushing. 🔗 https://typicode.github.io/husky/
"baseUrl": "./",
"paths": {
"@controllers/*": ["./src/controllers/*"],
"@models/*": ["./src/models/*"],
"@routes/*": ["./src/routes/*"],
"@services/*": ["./src/services/*"],
"@utils/*": ["./src/utils/*"],
"@constants/*": ["./src/constants/*"],
"@config/*": ["./src/config/*"]
},
- How to run tests:
npm run test or npm run test:watch
It has an example of tests with Jest + Testing-Library in src/tests/example.spec.tsx
import { UserModel } from '@models/user.model';
const sum = (numberA: number, numberB: number) => {
return numberA + numberB;
};
describe('User Model', () => {
it('should check if the name passed in the User model is Aleydon', () => {
const user = new UserModel('Aleydon', 29);
expect(user.name).toBe('Aleydon');
});
});
describe('Math', () => {
it('should sum two numbers correctly', () => {
const result = sum(1, 2);
expect(result).toBe(3);
});
});