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

valid-expect does not work with then #347

Closed
glickel opened this issue Jul 23, 2019 · 4 comments · Fixed by #352
Closed

valid-expect does not work with then #347

glickel opened this issue Jul 23, 2019 · 4 comments · Fixed by #352

Comments

@glickel
Copy link

glickel commented Jul 23, 2019

Hello, I have a problem with jest/valid-expect rule, it seems to not work when I put a .then after a .rejects or a .resolves like this:

return expect(functionReturningAPromise()).resolves.toEqual(1).then(() => {
    expect(someMock).toHaveBeenCalledTimes(1);
});

When I disable the rule jest/valid-expect or I remove the .then it works well.

@SimenB
Copy link
Member

SimenB commented Jul 23, 2019

I'd recommend using async-await instead

await expect(functionReturningAPromise()).resolves.toEqual(1)
expect(someMock).toHaveBeenCalledTimes(1);

However, the code you write is valid, so the rule shouldn't complain

/cc @yatki

@yatki
Copy link
Contributor

yatki commented Jul 25, 2019

@SimenB hopefully #352 would fix it.

SimenB pushed a commit that referenced this issue Jul 25, 2019
@SimenB
Copy link
Member

SimenB commented Jul 25, 2019

🎉 This issue has been resolved in version 22.13.7 🎉

The release is available on:

Your semantic-release bot 📦🚀

@glickel
Copy link
Author

glickel commented Jul 26, 2019

Thank you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants