@common-web/jest
v1.0.7
Published
Common jest configuration
Downloads
532
Readme
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');
// Defines the "src" of the test files
process.env.COMMON_JEST_ROOT = 'my/new/root';
// Support additional extensions in your application
process.env.COMMON_JEST_FILE_EXTENSIONS = 'svg';
// Add additional ignore patterns
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