should run yarn add --dev jest
should add scripts to watch and start tests in package.json
{
"scripts": {
"test": "jest --config jest.config.json",
"test:watch": "yarn test --watch",
"test:debug": "DEBUG=* yarn test --verbose",
"test:watch:debug": "yarn test:debug --watch",
"test:integration": "USE_REAL_API=true yarn test",
"test:integration:watch": "yarn test:integration --watch",
"test:integration:debug": "DEBUG=* yarn run test:integration --verbose",
"test:integration:debug:watch": "yarn run test:integration:debug --watch",
}
};
should create a jest.config.json file
{
"testEnvironment": "node",
};
should run yarn add --dev @types/jest ts-jest if we are using TS
should add transform to the jest.config.json file if we are using TS
{
"testEnvironment": "node",
"transform": {
"^.+\\.tsx?$": "ts-jest"
}
}
if in lerna monorepo root add to jest.config.json
{
"watchPlugins": ["jest-watch-lerna-packages"]
}
run
yarn add --dev jest-watch-lerna-packages