Do you want to request a _feature_ or report a _bug_?
A bug.
What is the current behavior?
The following assertion fails:
expect(Promise.resolve('Expected value')).resolves.toBe('Not the expected value');
It throws an error, but nevertheless, Jest marks the test as Passed. See this repl.it:
https://repl.it/repls/ObedientNegativeGrison
What is the expected behavior?
Jest should mention that the test failed.
Please provide your exact Jest configuration and mention your Jest, node,
yarn/npm version and operating system.
$ yarn run jest --version
v21.2.1
$ node --version
v6.11.3
$ yarn --version
1.3.2
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.3 LTS
Release: 16.04
Codename: xenial
You have to return (or await) the expect.
Oh really? Ugh, sorry for wasting your time - I thought that requirement had been removed with the addition of .resolves.
You still have to somehow tell jest to wait for it - it's still a promise 馃檪
Difference now is that you await the expect itself, and not the value within it
Hehe yeah it makes sense. Gives me some bad faith about all those tests I've already written without this measure :P I could submit a PR to emphasise this in the docs if you think that's a good idea?
Please do! All doc improvements are very welcome
@SimenB #4999 - almost at number 5000!
Most helpful comment
You have to
return(orawait) theexpect.http://facebook.github.io/jest/docs/en/expect.html#resolves