| applyTo | **/*.test.ts,**/*.spec.ts |
|---|
- Use the Jest testing framework.
- Place test files next to the source file, with
.test.tssuffix. - Use
describeanditblocks for organization. - Use
beforeEachfor setup andafterEachfor cleanup. - Use
expectassertions for results. - Mock dependencies to isolate the component under test.
- Mock external calls (e.g., AWS SDK, databases).
- Structure your tests using the Arrange-Act-Assert pattern:
- Arrange: Set up the test environment, including any necessary mocks and test data.
- Act: Execute the function or service being tested.
- Assert: Verify that the results are as expected.
- Add comments to separate these sections for clarity.
- Use
npm run testto run tests. - Use
npm run test:coverageto run tests with coverage report. - Use
npm run lintto run ESLint. - Use
npm run lint:fixto fix ESLint issues. - Use
npm run formatto run Prettier to format code. - Use
npm run format:checkto check code formatting with Prettier.