Common jest config
Supports typescript and modern es6 features out of the box in test code base, using the transformers:
the configuration defaults to looking for test files in the src/ folder under tests
Getting started
Install the pkg:
yarn:
yarn add @common-web/jest -D
npm:
npm install @common-web/jest --save-dev
in your repo create jest.config.js
file with the following code:
const commonConfig = require('@common-web/jest');
module.exports = commonConfig;
Changing common configurations, if you need to change paths or ignore certain files:
const commonConfig = require('@common-web/jest');
process.env.COMMON_JEST_ROOT = 'my/new/root';
process.env.COMMON_JEST_FILE_EXTENSIONS = 'svg';
process.env.COMMON_JEST_IGNORE_PATTERNS = 'dist/**';
module.exports = commonConfig;
Adding the script to (package.json)
{
...
"scripts": {
"test": "jest -c ./jest.config.js"
}
}
For more information and options for jest cli please see official docs - here
Running the jest
yarn run test
or
npm run test