Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expect rejects async/await documentation example fails #5076

Closed
brysgo opened this issue Dec 13, 2017 · 4 comments
Closed

Expect rejects async/await documentation example fails #5076

brysgo opened this issue Dec 13, 2017 · 4 comments

Comments

@brysgo
Copy link

brysgo commented Dec 13, 2017

Attempting to follow this documentation:

Alternatively, you can use async/await in combination with .rejects.
test('rejects to octopus', async () => {
  await expect(Promise.reject(new Error('octopus'))).rejects.toThrow('octopus');
});

I get the error:

$ jest
 FAIL  .\index.test.js
  × async error handling from docs (5ms)

  ● async error handling from docs

    expect(function).toThrow(string)

    Received value must be a function, but instead "object" was found

Steps to reproduce:

  1. mkdir test
  2. yarn add jest
  3. touch index.test.js
  4. paste above example from documentation
  1. run jest

Environment (most likely of little relevance here):
yarn 1.3.2
node v8.5.0
windows 7

@thymikee
Copy link
Collaborator

This will be fixed in Jest 22. You can try jest@test to get the latest beta where this issue was fixed (correct me if I'm wrong @SimenB).

@SimenB
Copy link
Member

SimenB commented Dec 13, 2017

Correct, see #4884, #4945 etc

@brysgo
Copy link
Author

brysgo commented Dec 13, 2017

homer simpson doh

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants