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

Correct erroneous rejects test example #6421

Closed
wants to merge 1 commit into from
Closed

Correct erroneous rejects test example #6421

wants to merge 1 commit into from

Conversation

kjarnet
Copy link

@kjarnet kjarnet commented Jun 8, 2018

Summary

as rejects will receive the rejected promise payload, not a function,
resulting in the following error message when the test was run:
Received value must be a function, but instead "object" was found

Test plan

Run the examples in Jest:

test('rejects to octopus', () => {
 return expect(Promise.reject(new Error('octopus'))).rejects.toHaveProperty(
   'message',
   'octopus'
  );
});
 test('rejects to octopus', async () => {
  await expect(Promise.reject(new Error('octopus'))).rejects.toHaveProperty(
    'message',
    'octopus'
  );
 });

Expected output:

Ran all test suites.

as `rejects` will receive the rejected promise payload, not a function,
resulting in the following error message when the test was run:
`Received value must be a function, but instead "object" was found`
@codecov-io
Copy link

Codecov Report

❗ No coverage uploaded for pull request base (master@397d7c1). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##             master    #6421   +/-   ##
=========================================
  Coverage          ?   63.48%           
=========================================
  Files             ?      227           
  Lines             ?     8697           
  Branches          ?        3           
=========================================
  Hits              ?     5521           
  Misses            ?     3175           
  Partials          ?        1

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 397d7c1...7c9d6d1. Read the comment docs.

@@ -24,7 +24,7 @@ class MyWatchPlugin {
## Hooking into Jest

To connect your watch plugin to Jest, add its path under `watchPlugins` in your Jest configuration:

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is from prettier 🤷‍♂️

@SimenB
Copy link
Member

SimenB commented Jun 16, 2018

Thanks for the PR!

I think you're on an old version of Jest - this was fixed in #4884.
Can you verify with Jest 22 or Jest 23?

@kjarnet
Copy link
Author

kjarnet commented Jun 17, 2018

Indeed, you're right! Sorry, was so sure we were on latest 😳

@kjarnet kjarnet closed this Jun 17, 2018
@github-actions
Copy link

This pull request 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 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants