core3-utils

@wixc3/testing on Github

Home > @wixc3/testing > chaiRetryPlugin

chaiRetryPlugin() function

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, { flag, inspect }: Chai.ChaiUtils) => void

Parameters

Parameter Type Description
\_ typeof Chai
{ flag, inspect } Chai.ChaiUtils

Returns:

void

Example 1

import Chai from 'chai';
import { chaiRetryPlugin } from '@wixc3/testing';

Chai.use(chaiRetryPlugin);

Examples of usage:

Example 2

await expect(funcToRetry).retry().have.property('value').and.be.above(4);

Example 3

await expect(sometimesNullFunction).retry({ retries: 5, delay: 10, timeout: 2000 }).to.be.not.null;

Example 4

await expect(funcToRetry).retry().and.have.property('success').and.be.true;