only-changed-jest-watch-plugin
v1.0.1
Published
Jest watch plugin for running either only the modified test (for TDD), or tests of dependant modules
Downloads
114
Readme
only-changed-jest-watch-plugin
Jest watch plugin for running either only the modified test (for TDD), or tests of dependent modules. Developed as using the -o
option to test for updated files only requires git, which isn't present in our dockerized containers.
Usage
Install
Install jest
(it needs Jest 23+) and only-changed-jest-watch-plugin
yarn add --dev jest only-changed-jest-watch-plugin
# or with NPM
npm install --save-dev jest only-changed-jest-watch-plugin
Add it to your Jest config
In your package.json
{
"jest": {
"watchPlugins": [
"only-changed-jest-watch-plugin"
]
}
}
Or in jest.config.js
module.exports = {
watchPlugins: [
'only-changed-jest-watch-plugin'
],
};
Configuring your key, prompt name and watch ignore path globs
module.exports = {
watchPlugins: [
[
'only-changed-jest-watch-plugin',
{
key: 'k',
prompt: 'My custom prompt',
watchPathIgnoreGlobs: ['**/node_modules/**', './node_modules/**']
},
],
],
};
Test naming and location conventions
This plugin expects tests to sit alongside in the same directory the module they are testing, and be named like my-module.test.js
e.g. module name postfixed with test/spec etc.
Run Jest in watch mode
yarn jest --watchAll