-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Closed
Description
🐛 Bug Report
mockResolvedValue and mockRejectedValue should return a real Promise testable with toBeInstanceOf but they don't.
To Reproduce
it('should returns a Promise', async () => {
const fn = jest.fn().mockResolvedValue(123);
const promise = fn();
expect(promise).toBeInstanceOf(Promise);
const result = await promise;
expect(result).toBe(123);
});Expected behavior
It should pass
The behaviour should be the same as using
const fn = jest.fn().mockReturnValue(Promise.resolve(123));Run npx envinfo --preset jest
Paste the results here:
npx: installed 1 in 1.878s
System:
OS: macOS High Sierra 10.13.5
CPU: x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
Binaries:
Node: 8.9.3 - ~/.nvm/versions/node/v8.9.3/bin/node
Yarn: 1.7.0 - /usr/local/bin/yarn
npm: 5.7.1 - ~/.nvm/versions/node/v8.9.3/bin/npm
npmPackages:
@types/jest: ^22.2.0 => 22.2.0
jest: ^22.4.3 => 22.4.4
JemarJones, whitehorse0, mct-dev, littleninja and yannbriancon
Metadata
Metadata
Assignees
Labels
No labels