Asynchronous matchers.
Members
not :async-matchers
Invert the matcher following this expectAsync
Type:
Examples
await expectAsync(myPromise).not.toBeResolved();
return expectAsync(myPromise).not.toBeResolved();
Methods
(async) toBeRejected()
Expect a promise to be rejected.
Examples
await expectAsync(aPromise).toBeRejected();
return expectAsync(aPromise).toBeRejected();
(async) toBeRejectedWith(expected)
Expect a promise to be rejected with a value equal to the expected, using deep equality comparison.
Parameters:
Name | Type | Description |
---|---|---|
expected |
Object | Value that the promise is expected to be rejected with |
Examples
await expectAsync(aPromise).toBeRejectedWith({prop: 'value'});
return expectAsync(aPromise).toBeRejectedWith({prop: 'value'});
(async) toBeResolved()
Expect a promise to be resolved.
Examples
await expectAsync(aPromise).toBeResolved();
return expectAsync(aPromise).toBeResolved();
(async) toBeResolvedTo(expected)
Expect a promise to be resolved to a value equal to the expected, using deep equality comparison.
Parameters:
Name | Type | Description |
---|---|---|
expected |
Object | Value that the promise is expected to resolve to |
Examples
await expectAsync(aPromise).toBeResolvedTo({prop: 'value'});
return expectAsync(aPromise).toBeResolvedTo({prop: 'value'});
withContext(message) → {async-matchers}
Add some context for an expectAsync
Parameters:
Name | Type | Description |
---|---|---|
message |
String | Additional context to show when the async matcher fails |
Returns:
- Type
- async-matchers