This is a Jest runner for es-check.
Install jest(it needs Jest 21+) and jest-runner-es-check
yarn add --dev jest jest-runner-es-check
# or with NPM
npm install --save-dev jest jest-runner-es-checkIn your package.json
{
"jest": {
"runner": "jest-runner-es-check",
"displayName": "es-check",
"testMatch": ["<rootDir>/dist/**/*.js"]
}
}Or in jest.config.js
module.exports = {
runner: 'jest-runner-es-check',
displayName: 'es-check',
testMatch: ['<rootDir>/dist/**/*.js'],
};It is recommended to use the projects configuration option to run multiple Jest runners simultaneously.
If you are using Jest <22.0.5, you can use multiple Jest configuration files and supply the paths to those files in the projects option. For example:
// jest-test.config.js
module.exports = {
// your Jest test options
displayName: 'test',
};
// jest-es-check.config.js
module.exports = {
// your jest-runner-es-check options
runner: 'jest-runner-es-check',
displayName: 'es-check',
testMatch: ['<rootDir>/dist/**/*.js'],
};In your package.json:
{
"jest": {
"projects": [
"<rootDir>/jest-test.config.js",
"<rootDir>/jest-es-check.config.js"
]
}
}Or in jest.config.js:
module.exports = {
projects: [
'<rootDir>/jest-test.config.js',
'<rootDir>/jest-es-check.config.js',
],
};If you are using Jest >=22.0.5, you can supply an array of project configuration objects instead. In your package.json:
{
"jest": {
"projects": [
{
"displayName": "test"
},
{
"runner": "jest-runner-es-check",
"displayName": "es-check",
"testMatch": ["<rootDir>/dist/**/*.js"]
}
]
}
}Or in jest.config.js:
module.exports = {
projects: [
{
displayName: 'test',
},
{
runner: 'jest-runner-es-check',
displayName: 'es-check',
testMatch: ['<rootDir>/dist/**/*.js'],
},
],
};This project uses same options as the original package, and will read .escheckrc in the root directory, if present. However, it's also easily configurable via jest's options:
// package.json
"jest": {
"runner": "jest-runner-es-check",
"displayName": "es-check",
"testEnvironmentOptions": {
"ecmaVersion": "es5"
},
"testMatch": [
"<rootDir>/dist/**/*.js"
]
}All available options:
ecmaVersion: The ECMA version to check against. One of:es3es4es5es6es2015es7es2016es8es2017es9es2018es10es2019
moduleSet totrueif files are using module syntax.allowHashBangSet to true if hashbangs should be allowed.
Check out the example to see it in action.