Optional
options: PartialWithUndefined<Optional
failureMessage: stringThe successful callback return value.
Repeatedly calls a callback until its output deeply equals (using the deep-eql package) the first input. Once the callback output passes, it is returned. If the attempts time out, an error is thrown.
Note that this check may be expensive, depending on what values it is passed. Whenever possible, use simpler equality checks instead (see the see section below).
Type guards the first value.
Optional
options: PartialWithUndefined<Optional
failureMessage: stringThe callback output once it passes.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.deepEquals('a', () => 'a'); // returns `'a'`
await waitUntil.deepEquals(1, () => '1'); // throws an error
await waitUntil.deepEquals({a: 'a'}, () => {
return {a: 'a'};
}); // returns `{a: 'a'}`
const objectExample = {a: 'a'};
await waitUntil.deepEquals(objectExample, () => objectExample); // returns `{a: 'a'}`
AssertionError On timeout.
Repeatedly calls a callback until its output string or array ends with the first input child value. This uses reference equality when the parent is an array. Once the callback output passes, it is returned. If the attempts time out, an error is thrown.
Performs no type guarding.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.endsWith('b', () => 'ab'); // returns `'ab'`
await waitUntil.endsWith('a', () => 'ab'); // throws an error
await waitUntil.endsWith('b', () => ['a', 'b']); // returns `['a', 'b']`
await waitUntil.endsWith('a', () => ['a', 'b']); // throws an error
AssertionError On timeout.
Repeatedly calls a callback until its output string or array does not end with the first input child value. This uses reference equality when the parent is an array. Once the callback output passes, it is returned. If the attempts time out, an error is thrown.
Performs no type guarding.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.endsWith('b', () => 'ab'); // throws an error
await waitUntil.endsWith('a', () => 'ab'); // returns `'ab'`
await waitUntil.endsWith('b', () => ['a', 'b']); // throws an error
await waitUntil.endsWith('a', () => ['a', 'b']); // returns `['a', 'b']`
AssertionError On timeout.
Repeatedly calls a callback until its output is deeply equal to the first input by
checking only their top-level values for strict (non-deep, reference, using
===
)
equality. Once the callback output passes, it is returned. If the attempts time out, an
error is thrown.
Type guards the first value.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.entriesEqual({a: 'a'}, () => {
return {a: 'a'};
}); // returns `{a: 'a'}`
await waitUntil.entriesEqual({a: {b: 'b'}}, () => {
return {a: {b: 'b'}};
}); // throws an error
const bExample = {b: 'b'};
await waitUntil.entriesEqual({a: bExample}, () => {
return {a: bExample};
}); // returns `{a: {b: 'b'}}`
AssertionError On timeout.
Repeatedly calls a callback until its output is a parent value that has the first, key input. Once the callback output passes, it is returned. If the attempts time out, an error is thrown.
Type guards the parent value.
Optional
options: PartialWithUndefined<Optional
failureMessage: stringThe callback output once it passes.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.hasKey('a', () => {
return {a: 0, b: 1};
}); // returns `{a: 0, b: 1}`
await waitUntil.hasKey('c', () => {
return {a: 0, b: 1};
}); // throws an error
AssertionError On timeout.
Repeatedly calls a callback until its output is a parent value that has all of the first, keys input. Once the callback output passes, it is returned. If the attempts time out, an error is thrown.
Type guards the parent value.
Optional
options: PartialWithUndefined<Optional
failureMessage: stringThe callback output once it passes.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.hasKeys(['a', 'b'], () => {
return {a: 0, b: 1};
}); // returns `{a: 0, b: 1}`
await waitUntil.hasKeys(['b', 'c'], () => {
return {a: 0, b: 1};
}); // throws an error
AssertionError On timeout.
Repeatedly calls a callback until its output is an object/array parent includes a child value through reference equality. Once the callback output passes, it is returned. If the attempts time out, an error is thrown.
Performs no type guarding.
Optional
options: PartialWithUndefined<Optional
failureMessage: stringThe callback output once it passes.
import {waitUntil} from '@augment-vir/assert';
const child = {a: 'a'};
await waitUntil.hasValue(child, () => {
return {child};
}); // returns `{child}`;
await waitUntil.hasValue(child, () => {
return {child: {a: 'a'}};
}); // throws an error
await waitUntil.hasValue(child, () => [child]); // returns `[child]`;
AssertionError On timeout.
Repeatedly calls a callback until its output is an object/array parent includes all child values through reference equality. Once the callback output passes, it is returned. If the attempts time out, an error is thrown.
Performs no type guarding.
Optional
options: PartialWithUndefined<Optional
failureMessage: stringThe callback output once it passes.
import {waitUntil} from '@augment-vir/assert';
const child = {a: 'a'};
const child2 = {b: 'b'};
await waitUntil.hasValues([child, child2], () => {
return {child, child2};
}); // returns `{child, child2}`;
await waitUntil.hasValues([child, child2], () => {
return {child: {a: 'a'}, child2};
}); // throws an error
await waitUntil.hasValues([child, child2], () => [child]); // returns `[child]`;
AssertionError On timeout.
Repeatedly calls a callback until its output is an instance of the given class constructor. Once the callback output passes, it is returned. If the attempts time out, an error is thrown.
Type guards the value.
Optional
options: PartialWithUndefined<Optional
failureMessage: stringThe callback output once it passes.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.instanceOf(RegExp, () => /abc/); // returns `/abc/`
await waitUntil.instanceOf(RegExp, () => 'abc'); // throws an error
AssertionError On timeout.
Repeatedly calls a callback until its output is a number that is above the expectation
(actual > expected
). Once the callback output passes, it is returned. If the attempts
time out, an error is thrown.
Performs no type guarding.
Optional
options: PartialWithUndefined<Optional
failureMessage: stringThe callback output once it passes.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.isAbove(5, () => 10); // returns `10`
await waitUntil.isAbove(5, () => 5); // throws an error
await waitUntil.isAbove(10, () => 5); // throws an error
AssertionError On timeout.
Repeatedly calls a callback until its output is a number that is within ±delta
of the
expectation. Once the callback output passes, it is returned. If the attempts time out,
an error is thrown.
Performs no type guarding.
Optional
options: PartialWithUndefined<Optional
failureMessage: stringThe callback output once it passes.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.isApproximately(8, 4, () => 10); // returns `10`
await waitUntil.isApproximately(12, 4, () => 10); // returns `10`
await waitUntil.isApproximately(8, 1, () => 10); // throws an error
await waitUntil.isApproximately(12, 1, () => 10); // throws an error
AssertionError If the assertion fails.
Repeatedly calls a callback until its output is an array. Once the callback output passes, it is returned. If the attempts time out, an error is thrown.
Type guards the value.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.isArray(() => []); // passes
await waitUntil.isArray(() => {
return {length: 4};
}); // throws an error
AssertionError If the assertion failed.
Repeatedly calls a callback until its output is a number that is at least the expectation
(actual >= expected
). Once the callback output passes, it is returned. If the attempts
time out, an error is thrown.
Performs no type guarding.
Optional
options: PartialWithUndefined<Optional
failureMessage: stringThe callback output once it passes.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.isAtLeast(5, () => 10); // returns `10`
await waitUntil.isAtLeast(5, () => 5); // returns `5`
await waitUntil.isAtLeast(10, () => 5); // throws an error
AssertionError On timeout.
Repeatedly calls a callback until its output is a number that is at most the expectation
(actual <= expected
). Once the callback output passes, it is returned. If the attempts
time out, an error is thrown.
Performs no type guarding.
Optional
options: PartialWithUndefined<Optional
failureMessage: stringThe callback output once it passes.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.isAtMost(5, () => 10); // throws an error
await waitUntil.isAtMost(5, () => 5); // returns `5`
await waitUntil.isAtMost(10, () => 5); // returns `5`
AssertionError On timeout.
Repeatedly calls a callback until its output is a number that is below the expectation
(actual < expected
). Once the callback output passes, it is returned. If the attempts
time out, an error is thrown.
Performs no type guarding.
Optional
options: PartialWithUndefined<Optional
failureMessage: stringThe callback output once it passes.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.isBelow(5, () => 10); // throws an error
await waitUntil.isBelow(5, () => 5); // throws an error
await waitUntil.isBelow(10, () => 5); // returns `5`
AssertionError On timeout.
Repeatedly calls a callback until its output is a BigInt. Once the callback output passes, it is returned. If the attempts time out, an error is thrown.
Type guards the value.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.isBigInt(() => 123n); // returns `123n`
await waitUntil.isBigInt(() => 123); // throws an error
AssertionError If the assertion failed.
Repeatedly calls a callback until its output is a boolean. Once the callback output passes, it is returned. If the attempts time out, an error is thrown.
Type guards the value.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.isBoolean(() => true); // returns `true`
await waitUntil.isBoolean(() => 'true'); // throws an error
AssertionError If the assertion failed.
Repeatedly calls a callback until its output is a value that is defined (not null
and
not undefined
). Once the callback output passes, it is returned. If the attempts time
out, an error is thrown.
Type guards the value.
Optional
options: PartialWithUndefined<Optional
failureMessage: stringThe callback output once it passes.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.isDefined(() => 0); // returns `0`
await waitUntil.isDefined(() => ''); // returns `''`
await waitUntil.isDefined(() => null); // throws an error
await waitUntil.isDefined(() => undefined); // throws an error
AssertionError On timeout.
Repeatedly calls a callback until its output is a value is empty. Supports strings, Maps, Sets, objects, and arrays. Once the callback output passes, it is returned. If the attempts time out, an error is thrown.
Type guards the value.
Optional
options: PartialWithUndefined<Optional
failureMessage: stringThe callback output once it passes.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.isEmpty(() => {
return {};
}); // returns `{}`;
await waitUntil.isEmpty(() => ''); // returns `''`;
await waitUntil.isEmpty(() => []); // returns `[]`;
await waitUntil.isEmpty(() => 'a'); // throws an error
await waitUntil.isEmpty(() => {
return {a: 'a'};
}); // throws an error
AssertionError On timeout.
Repeatedly calls a callback until its output is an enum member. Once the callback output passes, it is returned. If the attempts time out, an error is thrown.
Performs no type guarding.
Optional
options: PartialWithUndefined<Optional
failureMessage: stringThe callback output once it passes.
import {waitUntil} from '@augment-vir/assert';
enum MyEnum {
A = 'a',
B = 'b',
}
await waitUntil.isEnumValue(MyEnum, () => 'a'); // returns `'a'`
await waitUntil.isEnumValue(MyEnum, () => 'A'); // throws an error
AssertionError On timeout.
Repeatedly calls a callback until is output is an instance of the built-in Error
class
and compares it to the given ErrorMatchOptions, if provided. Once the callback
output passes, that Error is returned. If the attempts time out, an error is thrown.
Type guards the input.
Optional
options: PartialWithUndefined<Optional
failureMessage: stringThe callback output once it passes.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.isError(new Error()); // returns the error instance
await waitUntil.isError(new Error(), {matchMessage: 'hi'}); // throws an error
await waitUntil.isError({message: 'not an error'}); // throws an error
AssertionError On timeout.
Repeatedly calls a callback until its output is exactly false
. Once the callback output
passes, it is returned. If the attempts time out, an error is thrown.
Type guards the value.
Optional
options: PartialWithUndefined<Optional
failureMessage: stringThe callback output once it passes.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.isFalse(() => true); // throws an error
await waitUntil.isFalse(() => false); // returns `false`
await waitUntil.isFalse(() => 1); // throws an error
await waitUntil.isFalse(() => 0); // throws an error
AssertionError On timeout.
Repeatedly calls a callback until its output is falsy. Once the callback output passes, it is returned. If the attempts time out, an error is thrown.
Type guards the value.
Optional
options: PartialWithUndefined<Optional
failureMessage: stringThe callback output once it passes.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.isFalsy(() => true); // throws an error
await waitUntil.isFalsy(() => false); // returns `false`
await waitUntil.isFalsy(() => 1); // throws an error
await waitUntil.isFalsy(() => 0); // returns `0`
AssertionError On timeout.
Repeatedly calls a callback until its output is a number that is finite: meaning, not
NaN
and not Infinity
or -Infinity
. Once the callback output passes, it is returned.
If the attempts time out, an error is thrown.
Performs no type guarding.
Optional
options: PartialWithUndefined<Optional
failureMessage: stringThe callback output once it passes.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.isFinite(() => 10); // returns `10`
await waitUntil.isFinite(() => parseInt('invalid')); // throws an error
await waitUntil.isFinite(() => Infinity); // throws an error
await waitUntil.isFinite(() => -Infinity); // throws an error
AssertionError If the assertion fails.
Repeatedly calls a callback until its output is a function. Once the callback output passes, it is returned. If the attempts time out, an error is thrown.
Type guards the value.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.isFunction(() => () => {
return {};
}); // returns `{}`
await waitUntil.isFunction(() => {
return {};
}); // throws an error
AssertionError If the assertion failed.
Repeatedly calls a callback until its output is an HttpStatus. Once the callback output passes, it is returned. If the attempts time out, an error is thrown.
Type guards the value.
Optional
options: PartialWithUndefined<Optional
failureMessage: stringThe callback output once it passes.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.isHttpStatus(() => 400); // returns `400`
await waitUntil.isHttpStatus(() => 500); // returns `500`
await waitUntil.isHttpStatus(() => 99); // throws an error
AssertionError On timeout.
Repeatedly calls a callback until its output is an HttpStatus within a specific HttpStatusCategory. Once the callback output passes, it is returned. If the attempts time out, an error is thrown.
Type guards the value.
Optional
options: PartialWithUndefined<Optional
failureMessage: stringThe callback output once it passes.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.isHttpStatusCategory(HttpStatusCategory.ClientError, () => 400); // returns `400`
await waitUntil.isHttpStatusCategory(HttpStatusCategory.Success, () => 500); // throws an error more
await waitUntil.isHttpStatusCategory(HttpStatusCategory.Information, () => 99); // throws an error more
AssertionError On timeout.
Repeatedly calls a callback until its output is child value is contained within a parent object, array, or string through reference equality. Once the callback output passes, it is returned. If the attempts time out, an error is thrown.
Type guards the child when possible.
Optional
options: PartialWithUndefined<Optional
failureMessage: stringThe callback output once it passes.
import {waitUntil} from '@augment-vir/assert';
const child = {a: 'a'};
await waitUntil.isIn({child}, () => child); // returns `child`
await waitUntil.isIn('ab', () => 'a'); // returns `'a'`
await waitUntil.isIn(child, () => [child]); // returns `child`
await waitUntil.isIn({child: {a: 'a'}}, () => child); // throws an error
await waitUntil.isIn('bc', () => 'a'); // throws an error
AssertionError On timeout.
Repeatedly calls a callback until its output is a number is inside the provided min and max bounds, inclusive. If the attempts time out, an error is thrown.
Performs no type guarding.
import {waitUntil} from '@augment-vir/assert';
waitUntil.isInBounds(5, {min: 1, max: 10}); // passes
waitUntil.isInBounds(10, {min: 1, max: 10}); // passes
waitUntil.isInBounds(11, {min: 1, max: 10}); // fails
waitUntil.isInBounds(0, {min: 1, max: 10}); // fails
AssertionError If the assertion fails.
Repeatedly calls a callback until its output is a number that is either Infinity
or
-Infinity
. Once the callback output passes, it is returned. If the attempts time out,
an error is thrown.
Performs no type guarding.
Optional
options: PartialWithUndefined<Optional
failureMessage: stringThe callback output once it passes.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.isInfinite(() => 10); // throws an error
await waitUntil.isInfinite(() => parseInt('invalid')); // throws an error
await waitUntil.isInfinite(() => Infinity); // returns `Infinity`
await waitUntil.isInfinite(() => -Infinity); // returns `-Infinity`
AssertionError If the assertion fails.
Repeatedly calls a callback until its output is an integer. This has the same limitations as https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger. If the attempts time out, an error is thrown.
Performs no type guarding.
import {waitUntil} from '@augment-vir/assert';
waitUntil.isInteger(5); // passes
waitUntil.isInteger(5.0000000000000001); // passes
waitUntil.isInteger(5.1); // fails
waitUntil.isInteger(NaN); // fails
AssertionError If the assertion fails.
Repeatedly calls a callback until its output is a key that is contained within the first, parent value. Once the callback output passes, it is returned. If the attempts time out, an error is thrown.
Type guards the key.
Optional
options: PartialWithUndefined<Optional
failureMessage: stringThe callback output once it passes.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.isKeyof({a: 0, b: 1}, () => 'a'); // returns `'a'`
await waitUntil.isKeyof({a: 0, b: 1}, () => 'c'); // throws an error
AssertionError On timeout.
Repeatedly calls a callback until its output is an array or string that has at least the given length. Once the callback output passes, it is returned. If the attempts time out, an error is thrown.
Type guards an array into an AtLeastTuple. Performs no type guarding on a string.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.isLengthAtLeast(2, () => ['a', 'b', 'c']); // returns `['a', 'b', 'c']`
await waitUntil.isLengthAtLeast(3, () => ['a', 'b', 'c']); // returns `['a', 'b', 'c']`
await waitUntil.isLengthAtLeast(3, () => ['a', 'b']); // throws an error
AssertionError On timeout.
Repeatedly calls a callback until its output is an array or string that has exactly the given length. Once the callback output passes, it is returned. If the attempts time out, an error is thrown.
Type guards an array into a Tuple. Performs no type guarding on a string.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.isLengthAtLeast(2, () => ['a', 'b', 'c']); // throws an error
await waitUntil.isLengthAtLeast(3, () => ['a', 'b', 'c']); // returns `['a', 'b', 'c']`
await waitUntil.isLengthAtLeast(3, () => ['a', 'b']); // throws an error
AssertionError On timeout.
Repeatedly calls a callback until its output is a number that is
NaN
.
Once the callback output passes, it is returned. If the attempts time out, an error is
thrown.
Performs no type guarding.
Optional
options: PartialWithUndefined<Optional
failureMessage: stringThe callback output once it passes.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.isNaN(() => 10); // throws an error
await waitUntil.isNaN(() => parseInt('invalid')); // returns `NaN`
await waitUntil.isNaN(() => Infinity); // throws an error
AssertionError If the assertion fails.
Repeatedly calls a callback until its output is a number that is outside ±delta
of the
expectation. Once the callback output passes, it is returned. If the attempts time out,
an error is thrown.
Performs no type guarding.
Optional
options: PartialWithUndefined<Optional
failureMessage: stringThe callback output once it passes.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.isNotApproximately(8, 4, () => 10); // throws an error
await waitUntil.isNotApproximately(12, 4, () => 10); // throws an error
await waitUntil.isNotApproximately(8, 1, () => 10); // returns `10`
await waitUntil.isNotApproximately(12, 1, () => 10); // returns `10`
AssertionError If the assertion fails.
Repeatedly calls a callback until its output is not an array. Once the callback output passes, it is returned. If the attempts time out, an error is thrown.
Type guards the value.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.isNotArray(() => []); // throws an error
await waitUntil.isNotArray(() => {
return {length: 4};
}); // returns `{length: 4}`
AssertionError If the assertion failed.
Repeatedly calls a callback until its output is not a BigInt. Once the callback output passes, it is returned. If the attempts time out, an error is thrown.
Type guards the value.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.isNotBigInt(() => 123n); // throws an error
await waitUntil.isNotBigInt(() => 123); // returns `123`
AssertionError If the assertion failed.
Repeatedly calls a callback until its output is not a boolean. Once the callback output passes, it is returned. If the attempts time out, an error is thrown.
Type guards the value.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.isNotBoolean(() => true); // throws an error
await waitUntil.isNotBoolean(() => 'true'); // returns `'true'`
AssertionError If the assertion failed.
Repeatedly calls a callback until its output is a value is not empty. Supports strings, Maps, Sets, objects, and arrays. Once the callback output passes, it is returned. If the attempts time out, an error is thrown.
Type guards the value.
Optional
options: PartialWithUndefined<Optional
failureMessage: stringThe callback output once it passes.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.isNotEmpty(() => {
return {};
}); // throws an error
await waitUntil.isNotEmpty(() => ''); // throws an error
await waitUntil.isNotEmpty(() => []); // throws an error
await waitUntil.isNotEmpty(() => 'a'); // returns `'a'`;
await waitUntil.isNotEmpty(() => {
return {a: 'a'};
}); // returns `{a: 'a'}`;
AssertionError On timeout.
Repeatedly calls a callback until its output is not an enum member. Once the callback output passes, it is returned. If the attempts time out, an error is thrown.
Performs no type guarding.
Optional
options: PartialWithUndefined<Optional
failureMessage: stringThe callback output once it passes.
import {waitUntil} from '@augment-vir/assert';
enum MyEnum {
A = 'a',
B = 'b',
}
await waitUntil.isNotEnumValue(MyEnum, () => 'a'); // throws an error
await waitUntil.isNotEnumValue(MyEnum, () => 'A'); // returns `'A'`
AssertionError On timeout.
Repeatedly calls a callback until its output is not a function. Once the callback output passes, it is returned. If the attempts time out, an error is thrown.
Type guards the value.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.isNotFunction(() => () => {
return {};
}); // throws an error
await waitUntil.isNotFunction(() => {
return {};
}); // returns `{}`
AssertionError If the assertion failed.
Repeatedly calls a callback until its output is child value is not contained within a parent object, array, or string through reference equality. Once the callback output passes, it is returned. If the attempts time out, an error is thrown.
Type guards the child when possible.
Optional
options: PartialWithUndefined<Optional
failureMessage: stringThe callback output once it passes.
import {waitUntil} from '@augment-vir/assert';
const child = {a: 'a'};
await waitUntil.isNotIn({child}, () => child); // throws an error
await waitUntil.isNotIn('ab', () => 'a'); // throws an error
await waitUntil.isNotIn([child], () => child); // throws an error
await waitUntil.isNotIn({child: {a: 'a'}}, () => child); // returns `child`;
await waitUntil.isNotIn('bc', () => 'a'); // returns `'a'`;
AssertionError On timeout.
Repeatedly calls a callback until its output is not an integer. This has the same limitations, as https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger. If the attempts time out, an error is thrown.
Performs no type guarding.
import {waitUntil} from '@augment-vir/assert';
waitUntil.isNotInteger(5); // fails
waitUntil.isNotInteger(5.0000000000000001); // fails
waitUntil.isNotInteger(5.1); // passes
waitUntil.isNotInteger(NaN); // passes
AssertionError If the assertion fails.
Repeatedly calls a callback until its output is a key that is not contained within the first, parent value. Once the callback output passes, it is returned. If the attempts time out, an error is thrown.
Type guards the key.
Optional
options: PartialWithUndefined<Optional
failureMessage: stringThe callback output once it passes.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.isKeyof({a: 0, b: 1}, () => 'a'); // throws an error
await waitUntil.isKeyof({a: 0, b: 1}, () => 'c'); // returns `'c'`
AssertionError On timeout.
Repeatedly calls a callback until its output is not exactly null
. Once the callback
output passes, it is returned. If the attempts time out, an error is thrown.
Type guards the value.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.isNotNull(() => null); // throws an error
await waitUntil.isNotNull(() => undefined); // returns `undefined`
AssertionError If the assertion failed.
Repeatedly calls a callback until its output is not a number. This includes NaN
. Once
the callback output passes, it is returned. If the attempts time out, an error is
thrown.
Type guards the value.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.isNotNumber(() => 123); // throws an error
await waitUntil.isNotNumber(() => 123n); // returns `123n`
AssertionError If the assertion failed.
Repeatedly calls a callback until its output is not an object. This includes arrays. Once the callback output passes, it is returned. If the attempts time out, an error is thrown.
Type guards the value.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.isNotObject(() => {
return {};
}); // throws an error
await waitUntil.isNotObject(() => []); // returns `[]`
AssertionError If the assertion failed.
Repeatedly calls a callback until its output is a valid PropertyKey
. PropertyKey
is a
built-in TypeScript type which refers to all possible key types for a JavaScript object.
Once the callback output passes, it is returned. If the attempts time out, an error is
thrown.
Type guards the value.
Optional
options: PartialWithUndefined<Optional
failureMessage: stringThe callback output once it passes.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.isPropertyKey('key'); // returns `'key'`
await waitUntil.isPropertyKey(true); // throws an error
await waitUntil.isPropertyKey({}); // throws an error
AssertionError If the assertion fails.
Repeatedly calls a callback until its output is a not Promise
instance. Once the
callback output passes, it is returned. If the attempts time out, an error is thrown.
Type guards the value.
Optional
options: PartialWithUndefined<Optional
failureMessage: stringThe callback output once it passes.
import {waitUntil} from '@augment-vir/assert';
class CustomThenable {
constructor(public value: any) {}
then(onFulfilled?: AnyFunction, onRejected?: AnyFunction) {
return new CustomThenable(
onFulfilled ? onFulfilled(this.value) : this.value,
);
}
}
await waitUntil.isNotPromise(() => Promise.resolve(5)); // throws an error
await waitUntil.isNotPromise(() => new CustomThenable(5)); // returns the resolved `5`
await waitUntil.isNotPromise(() => 5); // returns the resolved `5`
AssertionError If the assertion fails.
Repeatedly calls a callback until its output is not a PromiseLike
. Once the callback
output passes, it is returned. If the attempts time out, an error is thrown.
PromiseLike
is TypeScript built-in type that has a .then
method and thus behaves like
a promise. This is also referred to as a "thenable". This enables the use of third-party
promise implementations that aren't instances of the built-in Promise
class.
Type guards the value.
Optional
options: PartialWithUndefined<Optional
failureMessage: stringThe callback output once it passes.
import {waitUntil} from '@augment-vir/assert';
class CustomThenable {
constructor(public value: any) {}
then(onFulfilled?: AnyFunction, onRejected?: AnyFunction) {
return new CustomThenable(
onFulfilled ? onFulfilled(this.value) : this.value,
);
}
}
await waitUntil.isNotPromiseLike(() => Promise.resolve(5)); // throws an error
await waitUntil.isNotPromiseLike(() => new CustomThenable(5)); // throws an error
await waitUntil.isNotPromiseLike(() => 5); // returns `5`
AssertionError If the assertion fails.
Repeatedly calls a callback until its output is not a valid PropertyKey
.
PropertyKey
is a built-in TypeScript type which refers to all possible key types for a
JavaScript object. Once the callback output passes, it is returned. If the attempts time
out, an error is thrown.
Type guards the value.
Optional
options: PartialWithUndefined<Optional
failureMessage: stringThe callback output once it passes.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.isNotPropertyKey('key'); // throws an error
await waitUntil.isNotPropertyKey(true); // returns `true`
await waitUntil.isNotPropertyKey({}); // returns `{}`
AssertionError If the assertion fails.
Repeatedly calls a callback until its output is not a string. Once the callback output passes, it is returned. If the attempts time out, an error is thrown.
Type guards the value.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.isNotString(() => ''); // throws an error
await waitUntil.isNotString(() => 5); // returns `5`
AssertionError If the assertion failed.
Repeatedly calls a callback until its output is not a symbol. Once the callback output passes, it is returned. If the attempts time out, an error is thrown.
Type guards the value.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.isNotSymbol(() => Symbol('my-symbol')); // throws an error
await waitUntil.isNotSymbol(() => 'my-symbol'); // returns `'my-symbol'`
AssertionError If the assertion failed.
Repeatedly calls a callback until its output is not exactly undefined
. Once the
callback output passes, it is returned. If the attempts time out, an error is thrown.
Type guards the value.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.isNotUndefined(() => undefined); // throws an error
await waitUntil.isNotUndefined(() => null); // returns `null`
AssertionError If the assertion failed.
Repeatedly calls a callback until its output is not a valid UUID. The nil or max UUIDs are included as not valid. Returns the value if the assertion passes. Once the callback output passes, it is returned. If the attempts time out, an error is thrown.
Type guards the value.
Optional
options: PartialWithUndefined<Optional
failureMessage: stringThe callback output once it passes.
import {waitUntil} from '@augment-vir/assert';
import {createUuidV4} from '@augment-vir/common';
await waitUntil.isNotUuid(() => createUuidV4()); // throws an error
await waitUntil.isNotUuid(() => '29e0f18e-6115-4982-8342-0afcadf5d611'); // throws an error
await waitUntil.isNotUuid(() => '00000000-0000-0000-0000-000000000000'); // returns `'00000000-0000-0000-0000-000000000000'`
await waitUntil.isNotUuid(() => 'FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF'); // returns `'FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF'`
await waitUntil.isNotUuid(() => 'not-a-uuid'); // returns `'not-a-uuid'`
AssertionError On timeout.
Repeatedly calls a callback until its output is exactly null
. Once the callback output
passes, it is returned. If the attempts time out, an error is thrown.
Type guards the value.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.isNull(() => null); // returns `null`
await waitUntil.isNull(() => undefined); // throws an error
AssertionError If the assertion failed.
Repeatedly calls a callback until its output is a value that is nullish (null
or
undefined
). Once the callback output passes, it is returned. If the attempts time out,
an error is thrown.
Type guards the value.
Optional
options: PartialWithUndefined<Optional
failureMessage: stringThe callback output once it passes.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.isNullish(() => 0); // throws an error
await waitUntil.isNullish(() => ''); // throws an error
await waitUntil.isNullish(() => null); // returns `null`
await waitUntil.isNullish(() => undefined); // returns `undefined`
AssertionError On timeout.
Repeatedly calls a callback until its output is a number. This excludes NaN
. Once the
callback output passes, it is returned. If the attempts time out, an error is thrown.
Type guards the value.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.isNumber(() => 123); // returns `123`
await waitUntil.isNumber(() => 123n); // throws an error
AssertionError If the assertion failed.
Repeatedly calls a callback until its output is an object. This excludes arrays. Once the callback output passes, it is returned. If the attempts time out, an error is thrown.
Type guards the value.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.isObject(() => {
return {};
}); // returns `{}`
await waitUntil.isObject(() => []); // throws an error
AssertionError If the assertion failed.
Repeatedly calls a callback until its output is outside the provided min and max bounds, exclusive. If the attempts time out, an error is thrown.
Performs no type guarding.
import {waitUntil} from '@augment-vir/assert';
waitUntil.isOutBounds(5, {min: 1, max: 10}); // fails
waitUntil.isOutBounds(10, {min: 1, max: 10}); // fails
waitUntil.isOutBounds(11, {min: 1, max: 10}); // passes
waitUntil.isOutBounds(0, {min: 1, max: 10}); // passes
AssertionError If the assertion fails.
Repeatedly calls a callback until its output is a JavaScript primitive. Once the callback output passes, it is returned. If the attempts time out, an error is thrown.
Type guards the value.
Optional
options: PartialWithUndefined<Optional
failureMessage: stringThe callback output once it passes.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.isPrimitive('key'); // returns `'key'`
await waitUntil.isPrimitive(true); // returns `true`
await waitUntil.isPrimitive({}); // throws an error
AssertionError If the assertion fails.
Repeatedly calls a callback until its output is a Promise
instance. Once the callback
output passes, it is returned. If the attempts time out, an error is thrown.
Type guards the value.
Optional
options: PartialWithUndefined<Optional
failureMessage: stringThe callback output once it passes.
import {waitUntil} from '@augment-vir/assert';
class CustomThenable {
constructor(public value: any) {}
then(onFulfilled?: AnyFunction, onRejected?: AnyFunction) {
return new CustomThenable(
onFulfilled ? onFulfilled(this.value) : this.value,
);
}
}
await waitUntil.isPromise(() => Promise.resolve(5)); // returns the resolved `5`
await waitUntil.isPromise(() => new CustomThenable(5)); // throws an error
await waitUntil.isPromise(() => 5); // throws an error
AssertionError If the assertion fails.
Repeatedly calls a callback until its output is a PromiseLike
. Once the callback output
passes, it is returned. If the attempts time out, an error is thrown.
PromiseLike
is TypeScript built-in type that has a .then
method and thus behaves like
a promise. This is also referred to as a "thenable". This enables the use of third-party
promise implementations that aren't instances of the built-in Promise
class.
Type guards the value.
Optional
options: PartialWithUndefined<Optional
failureMessage: stringThe callback output once it passes.
import {waitUntil} from '@augment-vir/assert';
class CustomThenable {
constructor(public value: any) {}
then(onFulfilled?: AnyFunction, onRejected?: AnyFunction) {
return new CustomThenable(
onFulfilled ? onFulfilled(this.value) : this.value,
);
}
}
await waitUntil.isPromiseLike(() => Promise.resolve(5)); // returns the resolved `5`
await waitUntil.isPromiseLike(() => new CustomThenable(5)); // returns the resolved `5`
await waitUntil.isPromiseLike(() => 5); // throws an error
AssertionError If the assertion fails.
Repeatedly calls a callback until its output is not a JavaScript primitive. Once the callback output passes, it is returned. If the attempts time out, an error is thrown.
Type guards the value.
Optional
options: PartialWithUndefined<Optional
failureMessage: stringThe callback output once it passes.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.isPrimitive('key'); // throws an error
await waitUntil.isPrimitive(true); // throws an error
await waitUntil.isPrimitive({}); // returns `{}`
AssertionError If the assertion fails.
Repeatedly calls a callback until its output is a string. Once the callback output passes, it is returned. If the attempts time out, an error is thrown.
Type guards the value.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.isString(() => ''); // returns `''`
await waitUntil.isString(() => 5); // throws an error
AssertionError If the assertion failed.
Repeatedly calls a callback until its output is a symbol. Once the callback output passes, it is returned. If the attempts time out, an error is thrown.
Type guards the value.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.isSymbol(() => Symbol('my-symbol')); // returns the created symbol
await waitUntil.isSymbol(() => 'my-symbol'); // throws an error
AssertionError If the assertion failed.
Repeatedly calls a callback until its output is exactly true
. Once the callback output
passes, it is returned. If the attempts time out, an error is thrown.
Type guards the value.
Optional
options: PartialWithUndefined<Optional
failureMessage: stringThe callback output once it passes.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.isTrue(() => true); // returns `true`
await waitUntil.isTrue(() => false); // throws an error
await waitUntil.isTrue(() => 1); // throws an error
await waitUntil.isTrue(() => 0); // throws an error
AssertionError On timeout.
Repeatedly calls a callback until its output is truthy. Once the callback output passes, it is returned. If the attempts time out, an error is thrown.
Type guards the value.
Optional
options: PartialWithUndefined<Optional
failureMessage: stringThe callback output once it passes.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.isTruthy(() => true); // returns `true`
await waitUntil.isTruthy(() => false); // throws an error
await waitUntil.isTruthy(() => 1); // returns `1`
await waitUntil.isTruthy(() => 0); // throws an error
AssertionError On timeout.
Repeatedly calls a callback until its output is exactly undefined
. Once the callback
output passes, it is returned. If the attempts time out, an error is thrown.
Type guards the value.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.isUndefined(() => undefined); // returns `undefined`
await waitUntil.isUndefined(() => null); // throws an error
AssertionError If the assertion failed.
Repeatedly calls a callback until its output is a valid UUID. Does not accept the nil or max UUIDs. Returns the value if the assertion passes. Once the callback output passes, it is returned. If the attempts time out, an error is thrown.
Type guards the value.
Optional
options: PartialWithUndefined<Optional
failureMessage: stringThe callback output once it passes.
import {waitUntil} from '@augment-vir/assert';
import {createUuidV4} from '@augment-vir/common';
await waitUntil.isUuid(() => createUuidV4()); // returns the generated value
await waitUntil.isUuid(() => '29e0f18e-6115-4982-8342-0afcadf5d611'); // returns `'29e0f18e-6115-4982-8342-0afcadf5d611'`
await waitUntil.isUuid(() => '00000000-0000-0000-0000-000000000000'); // throws an error
await waitUntil.isUuid(() => 'FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF'); // throws an error
await waitUntil.isUuid(() => 'not-a-uuid'); // throws an error
AssertionError On timeout.
Repeatedly calls a callback until its output is deeply equal to the first input when stringified into JSON. This may not make any sense if the values are not valid JSON. This internally sorts all given object keys so it is insensitive to object key order. Once the callback output passes, it is returned. If the attempts time out, an error is thrown.
Type guards the first value.
Optional
options: PartialWithUndefined<Optional
failureMessage: stringThe callback output once it passes.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.jsonEquals({a: 'a'}, () => {
return {a: 'a'};
}); // returns `{a: 'a'}`
await waitUntil.jsonEquals({a: {b: 'c'}}, () => {
return {a: {b: 'b'}};
}); // throws an error
AssertionError On timeout.
Repeatedly calls a callback until its output is a parent value that does not have the first, key input. Once the callback output passes, it is returned. If the attempts time out, an error is thrown.
Type guards the parent value.
Optional
options: PartialWithUndefined<Optional
failureMessage: stringThe callback output once it passes.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.hasKey('a', () => {
return {a: 0, b: 1};
}); // throws an error
await waitUntil.hasKey('c', () => {
return {a: 0, b: 1};
}); // returns `{a: 0, b: 1}`
AssertionError On timeout.
Repeatedly calls a callback until its output is a parent value that does not have any of the first, keys input. Once the callback output passes, it is returned. If the attempts time out, an error is thrown.
Type guards the parent value.
Optional
options: PartialWithUndefined<Optional
failureMessage: stringThe callback output once it passes.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.hasKeys(['a', 'b'], () => {
return {a: 0, b: 1};
}); // throws an error
await waitUntil.hasKeys(['b', 'c'], () => {
return {a: 0, b: 1};
}); // returns `{a: 0, b: 1}`
AssertionError On timeout.
Repeatedly calls a callback until its output is an object/array parent does not include a child value through reference equality. Once the callback output passes, it is returned. If the attempts time out, an error is thrown.
Performs no type guarding.
Optional
options: PartialWithUndefined<Optional
failureMessage: stringThe callback output once it passes.
import {waitUntil} from '@augment-vir/assert';
const child = {a: 'a'};
await waitUntil.lacksValue(child, () => {
return {child};
}); // throws an error
await waitUntil.lacksValue(child, () => {
return {child: {a: 'a'}};
}); // returns `{child: {a: 'a'}}`;
await waitUntil.lacksValue(child, () => [child]); // throws an error
AssertionError On timeout.
Repeatedly calls a callback until its output is an object/array parent includes none of the provided child values through reference equality. Once the callback output passes, it is returned. If the attempts time out, an error is thrown.
Performs no type guarding.
Optional
options: PartialWithUndefined<Optional
failureMessage: stringThe callback output once it passes.
import {waitUntil} from '@augment-vir/assert';
const child = {a: 'a'};
const child2 = {b: 'b'};
await waitUntil.lacksValues([child, child2], () => {
return {};
}); // returns `{}`;
await waitUntil.lacksValues([child, child2], () => {
return {child, child2};
}); // throws an error
await waitUntil.lacksValues([child, child2], () => {
return {child: {a: 'a'}, child2};
}); // throws an error
AssertionError On timeout.
Repeatedly calls a callback until its output loosely equals (using
==
)
the first input. Once the callback output passes, it is returned. If the attempts time
out, an error is thrown.
Type guards the first value.
Optional
options: PartialWithUndefined<Optional
failureMessage: stringThe callback output once it passes.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.looseEquals('a', () => 'a'); // returns `'a'`
await waitUntil.looseEquals(1, () => '1'); // returns `'1'`
await waitUntil.looseEquals({a: 'a'}, () => {
return {a: 'a'};
}); // throws an error
const objectExample = {a: 'a'};
await waitUntil.looseEquals(objectExample, () => objectExample); // returns `{a: 'a'}`
AssertionError On timeout.
Repeatedly calls a callback until its output is a string that matches a RegExp (first
input, expected
). Once the callback output passes, it is returned. If the attempts time
out, an error is thrown.
Performs no type guarding.
Optional
options: PartialWithUndefined<Optional
failureMessage: stringThe callback output once it passes.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.matches(/^h/, () => 'hi'); // returns `'hi'`
await waitUntil.matches(/^g/, () => 'hi'); // throws an error
AssertionError If the assertion fails.
Repeatedly calls a callback until its output is a string that does not match a RegExp
(first input, expected
). Once the callback output passes, it is returned. If the
attempts time out, an error is thrown.
Performs no type guarding.
Optional
options: PartialWithUndefined<Optional
failureMessage: stringThe callback output once it passes.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.mismatches(/^h/, () => 'hi'); // throws an error
await waitUntil.mismatches(/^g/, () => 'hi'); // returns `'hi'`
AssertionError If the assertion fails.
Repeatedly calls a callback until its output does not deeply equal (using the deep-eql package) the first input. Once the callback output passes, it is returned. If the attempts time out, an error is thrown.
Note that this check may be expensive, depending on what values it is passed. Whenever possible, use simpler equality checks instead (see the see section below).
Type guards the first value.
Optional
options: PartialWithUndefined<Optional
failureMessage: stringThe callback output once it passes.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.notDeepEquals('a', () => 'a'); // throws an error
await waitUntil.notDeepEquals(1, () => '1'); // returns `'1'`
await waitUntil.notDeepEquals({a: 'a'}, () => {
return {a: 'a'};
}); // throws an error
const objectExample = {a: 'a'};
await waitUntil.notDeepEquals(objectExample, () => objectExample); // throws an error
AssertionError On timeout.
Repeatedly calls a callback until its output is not deeply equal to the first input by
checking only their top-level values for strict (non-deep, reference, using
===
)
equality. Once the callback output passes, it is returned. If the attempts time out, an
error is thrown.
Performs no type guarding.
Optional
options: PartialWithUndefined<Optional
failureMessage: stringThe callback output once it passes.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.notEntriesEqual({a: 'a'}, () => {
return {a: 'a'};
}); // throws an error
await waitUntil.notEntriesEqual({a: {b: 'b'}}, () => {
return {a: {b: 'b'}};
}); // returns `{a: {b: 'b'}}`
const bExample = {b: 'b'};
await waitUntil.notEntriesEqual({a: bExample}, () => {
return {a: bExample};
}); // throws an error
AssertionError If both inputs are equal.
Repeatedly calls a callback until its output is not an instance of the given class constructor. Once the callback output passes, it is returned. If the attempts time out, an error is thrown.
Type guards the value.
Optional
options: PartialWithUndefined<Optional
failureMessage: stringThe callback output once it passes.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.instanceOf(RegExp, () => /abc/); // throws an error
await waitUntil.instanceOf(RegExp, () => 'abc'); // returns `'abc'`
AssertionError On timeout.
Repeatedly calls a callback until its output is not deeply equal to the first input when stringified into JSON. This may not make any sense if the values are not valid JSON. This internally sorts all given object keys so it is insensitive to object key order. Once the callback output passes, it is returned. If the attempts time out, an error is thrown.
Performs no type guarding.
Optional
options: PartialWithUndefined<Optional
failureMessage: stringThe callback output once it passes.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.notJsonEquals({a: 'a'}, () => {
return {a: 'a'};
}); // throws an error
await waitUntil.notJsonEquals({a: {b: 'c'}}, () => {
return {a: {b: 'b'}};
}); // returns `{a: {b: 'b'}}`
AssertionError On timeout.
Repeatedly calls a callback until its output does not loosely equal (using
==
)
the first input. Once the callback output passes, it is returned. If the attempts time
out, an error is thrown.
Type guards the first value.
Optional
options: PartialWithUndefined<Optional
failureMessage: stringThe callback output once it passes.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.notLooseEquals('a', () => 'a'); // throws an error
await waitUntil.notLooseEquals(1, () => '1'); // throws an error
await waitUntil.notLooseEquals({a: 'a'}, () => {
return {a: 'a'};
}); // returns `{a: 'a'}`
const objectExample = {a: 'a'};
await waitUntil.notLooseEquals(objectExample, () => objectExample); // throws an error
AssertionError On timeout.
Repeatedly calls a callback until its output does not strictly equal (using
===
)
the first input. Once the callback output passes, it is returned. If the attempts time
out, an error is thrown.
Performs no type guarding.
Optional
options: PartialWithUndefined<Optional
failureMessage: stringThe callback output once it passes.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.notStrictEquals('a', () => 'a'); // throws an error
await waitUntil.notStrictEquals(1, () => '1'); // returns `'1'`
await waitUntil.notStrictEquals({a: 'a'}, () => {
return {a: 'a'};
}); // returns `{a: 'a'}`
const objectExample = {a: 'a'};
await waitUntil.notStrictEquals(objectExample, () => objectExample); // throws an error
AssertionError On timeout.
Repeatedly calls a callback until its output deeply equals expectations. A custom asserter can optionally be provided as the first argument to change the expectation checking from the default "deeply equals" to whatever you want.
Performs no type guarding.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.output((input: number) => String(input), [5], '5'); // returns `'5'`
await waitUntil.output((input: number) => String(input), [10], '5'); // throws an error
await waitUntil.output(
assert.isLengthAtLeast,
(input: number) => String(input),
[5],
2,
); // throws an error
await waitUntil.output(
assert.isLengthAtLeast,
(input: number) => String(input),
[10],
2,
); // returns `10`
AssertionError If the assertion fails.
Repeatedly calls a callback until its output string or array starts with the first input child value. This uses reference equality when the parent is an array. Once the callback output passes, it is returned. If the attempts time out, an error is thrown.
Performs no type guarding.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.endsWith('b', () => 'ab'); // throws an error
await waitUntil.endsWith('a', () => 'ab'); // returns `'ab'`
await waitUntil.endsWith('b', () => ['a', 'b']); // throws an error
await waitUntil.endsWith('a', () => ['a', 'b']); // returns `['a', 'b']`
AssertionError On timeout.
Repeatedly calls a callback until its output string or array does not start with the first input child value. This uses reference equality when the parent is an array. Once the callback output passes, it is returned. If the attempts time out, an error is thrown.
Performs no type guarding.
await waitUntil.endsWith('b', () => 'ab'); // returns `'ab'`
await waitUntil.endsWith('a', () => 'ab'); // throws an error
await waitUntil.endsWith('b', () => ['a', 'b']); // returns `['a', 'b']`
await waitUntil.endsWith('a', () => ['a', 'b']); // throws an error
AssertionError On timeout.
Repeatedly calls a callback until its output strictly equals (using
===
)
the first input. Once the callback output passes, it is returned. If the attempts time
out, an error is thrown.
Type guards the first value.
Optional
options: PartialWithUndefined<Optional
failureMessage: stringThe callback output once it passes.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.strictEquals('a', () => 'a'); // returns `'a'`
await waitUntil.strictEquals(1, () => '1'); // throws an error
await waitUntil.strictEquals({a: 'a'}, () => {
return {a: 'a'};
}); // throws an error
const objectExample = {a: 'a'};
await waitUntil.strictEquals(objectExample, () => objectExample); // returns `{a: 'a'}`
AssertionError On timeout.
Repeatedly calls a callback until it throws an error, comparing the error with the given ErrorMatchOptions, if provided (as the first input). Once the callback throws an Error, that Error is returned. If the attempts time out, an error is thrown.
This assertion will automatically type itself as async vs async based on the input. (A promise or async function inputs results in async. Otherwise, sync.)
Unlike the other .throws
guards, waitUntil.throws
does not allow a Promise input,
only a callback input.
Performs no type guarding.
import {waitUntil} from '@augment-vir/assert';
await waitUntil.throws(() => {
throw new Error();
}); // returns the thrown error
await waitUntil.throws(Promise.reject()); // not allowed
await waitUntil.throws(() => {}); // throws an error
await waitUntil.throws({matchMessage: 'hi'}, () => {
throw new Error('bye');
}); // throws an error
AssertionError On timeout.
A group of guard methods that run the given callback multiple times until its return value matches expectations. Callback interval and timeout can be customized with WaitUntilOptions.
This can also be called as a standalone wait until function which waits until the callback's returned value is truthy.
Example
Throws
AssertionError When the assertion fails.
Package
@augment-vir/assert