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

Redundant use of `await` on a return value. #1209

Closed
TheEnmanuel23 opened this issue Oct 8, 2018 · 2 comments

Comments

@TheEnmanuel23
Copy link

commented Oct 8, 2018

What version of standard?
12.0.1
What operating system, Node.js, and npm version?
macOS sierra v10.12.5
node: v8.9.3
npm: 5.5.1
What did you expect to happen?
No error, I have test with jest

image

in the version 11.0.1 it is working well for me

What actually happened?
throws error in the tests with async await
image

@TheEnmanuel23

This comment has been minimized.

Copy link
Author

commented Oct 8, 2018

the solution that I found is
it('/with empty array', async () => { await expect(tipState.saveInitialStates([])).rejects.toMatchObject({ message: /states parameter is empty/ }) })

adding {} in arrow function

@LinusU

This comment has been minimized.

Copy link
Member

commented Oct 10, 2018

This is intentional, it's because

async () => await foobar()

is the same as

async () => { return await foobar() }

which then has a redundant await, since the following will produce the same result:

async () => { return foobar() }

If you did not intend to return the return value of expect in the it-callback, I suggest changing to async () => { await ... } as you did, as that will only settle with undefined 👍

@lock lock bot locked as resolved and limited conversation to collaborators Jan 8, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
2 participants
You can’t perform that action at this time.