@wishtack/jest-tcr
is an implementation of TCR (Test && Commit || Revert
) which is an idea from Oddmund Strømme.
In order to reduce code asymmetry by producing the most atomic changes to the code, every time you run the tests, TCR will commit if the tests pass and revert if they fail.
yarn add -D @wishtack/jest-tcr
npm install --dev @wishtack/jest-tcr
Create a dedicated jest configuration jest.config.tcr.js
next to jest.config.js
with the following content:
const config = require('./jest.config');
module.exports = {
...config,
reporters: [
'default',
'@wishtack/jest-tcr'
]
};
{
...
"scripts": {
"jest:tcr": "jest --config jest.config.tcr.js --onlyChanged"
},
...
}
yarn jest:tcr
or npm run jest:tcr
If you don't want to revert your spec files when tests fail, you can tell @wishtack/jest-tcr
not to reset specs using the following configuration:
const config = require('./jest.config');
module.exports = {
...config,
reporters: [
'default',
['@wishtack/jest-tcr', {
revertBlacklistPattern: /spec\.ts$/
}]
]
};