Jest
Configuration Commands
Configure Jest for your project with jest.config.ts, setup files, module mappers, and transform settings. Properly configured Jest makes testing fast and reliable.
8 commands
Pro Tips
Use 'jest --init' to generate a starter config file with guided prompts for your project type.
Map path aliases with 'moduleNameMapper': { '^@/(.*)': '<rootDir>/src/$1' } to match your tsconfig paths.
Use 'projects' in jest config to run different configurations (e.g., unit and integration) in a single command.
Common Mistakes
Avoid 'transformIgnorePatterns' that exclude node_modules you need transformed. ESM packages often need transformation.
Setting 'testEnvironment: jsdom' for all tests slows Node.js-only tests. Use per-file docblocks: /** @jest-environment node */.