Automatically retry flaky tests with Jest
npm install jest-retries
npm i -D jest-retries
`
`js
const retry = require('jest-retries');
retry('Do flaky work', 5, () => {
expect(irregularFunction()).toBe('sporadic');
});
`
That's it!
No configurations, no arguments, just require jest-retries and use it instead of test().
$3
You sure can!
`js
const test = require('jest-retries');
function getRandomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min)) + min;
}
test('Random value should eventually resolve to 1', 100, () => {
expect(getRandomInt(0, 2)).toBe(1);
});
``