Home > @wixc3/testing > chaiRetryPlugin
Plugin that allows to re-run function passed to expect
, in order to achieve that use new retry
method, retrying would be performed until the result will pass the chained assertion or timeout exceeded or retries limit reached. Should be applied through Chai.use
function, for example:
Signature:
chaiRetryPlugin: (_: typeof Chai, utils: Chai.ChaiUtils) => void
Parameter | Type | Description |
---|---|---|
\_ | typeof Chai | |
utils | Chai.ChaiUtils |
Returns:
void
import Chai from 'chai';
import { chaiRetryPlugin } from '@wixc3/testing';
Chai.use(chaiRetryPlugin);
Examples of usage:
await expect(funcToRetry).retry().have.property('value').and.be.above(4);
await expect(sometimesNullFunction).retry({ retries: 5, delay: 10, timeout: 2000 }).to.be.not.null;
await expect(funcToRetry).retry().and.have.property('success').and.be.true;