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

fix: assertions error message #1027

Merged
merged 1 commit into from Mar 25, 2022
Merged

Conversation

ouduidui
Copy link
Contributor

I find expect.assertions error message is inaccurate when it is asynchronous code.

The following example, it will throw a error that message is Error: expected number of assertions to be 2, but got 0.

But the accurate message is Error: expected number of assertions to be 2, but got 3.

test('assertions when asynchronous code', async() => {
  expect.assertions(2)
  await Promise.all([
    expect(1).toBe(1),
    expect(1).toBe(1),
    expect(1).toBe(1),
  ])
})

Reproduction: https://stackblitz.com/edit/node-misjca

@netlify
Copy link

netlify bot commented Mar 25, 2022

Deploy Preview for vitest-dev ready!

Name Link
🔨 Latest commit 4955b39
🔍 Latest deploy log https://app.netlify.com/sites/vitest-dev/deploys/623d60641ef3bd0009bbe611
😎 Deploy Preview https://deploy-preview-1027--vitest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@antfu antfu merged commit f52cd93 into vitest-dev:main Mar 25, 2022
@ouduidui ouduidui deleted the fix-assertions branch March 25, 2022 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants