-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Description
See #3068.
Do you want to request a feature or report a bug?
Feature request and/or unexpected behavior
What is the current behavior?
While the new resolves and rejects flags naturally pass Promise values/errors to their matchers, the matchers themselves don't return Promises that resolve with the value of their received Promise. If it's possible to implement, this feature would be useful for chaining expectations for the same async value.
If the current behavior is a bug, please provide the steps to reproduce and either a repl.it demo through https://repl.it/languages/jest or a minimal repository on GitHub that we can yarn install and yarn test.
test('Return received results in Promise matchers', async () => {
const received = await expect(Promise.resolve(true)).resolves.toBeTruthy()
return expect(received).toBeTruthy()
}) FAIL test.js
● Return received results in Promise matchers
expect(received).toBeTruthy()
Expected value to be truthy, instead received
undefined
What is the expected behavior?
The test would pass if this was implemented. A workaround is to save the value to an awaited variable and avoid resolves/rejects.
Please provide your exact Jest configuration and mention your Jest, node, yarn/npm version and operating system.