You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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()=>{constreceived=awaitexpect(Promise.resolve(true)).resolves.toBeTruthy()returnexpect(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.
I prefer not to support chaining for now. The workaround sounds good to me; if you need the values multiple times, I recommend calling await on the actual thing rather than the matcher.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.
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
andrejects
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
andyarn test
.What is the expected behavior?
The test would pass if this was implemented. A workaround is to save the value to an
await
ed variable and avoidresolves
/rejects
.Please provide your exact Jest configuration and mention your Jest, node, yarn/npm version and operating system.
[email protected]
The text was updated successfully, but these errors were encountered: