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

.not.toThrowErrorMatchingInlineSnapshot() doesn't work as expected #3089

Closed
6 tasks done
Maxim-Mazurok opened this issue Mar 28, 2023 · 2 comments
Closed
6 tasks done
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)

Comments

@Maxim-Mazurok
Copy link
Contributor

Maxim-Mazurok commented Mar 28, 2023

Describe the bug

I created a failing test using .not.toThrowErrorMatchingInlineSnapshot() to demonstrate to my colleague the error that they have to address.
However, when they fixed the error - the test still doesn't pass, because vitest returns Error: snapshot function didn't throw for this test.
I expect .not.toThrowErrorMatchingInlineSnapshot() to assert that error was either not thrown, or it was thrown but didn't match the snapshot.
Current behaviour is more like expect().toTrowError.not.matchingInlineSnapshot(), hope this makes sense!

Reproduction

https://stackblitz.com/edit/vitest-dev-vitest-cmmyai?file=test/basic.test.ts

// passes
it("throws", () => {
  expect(() => {
    throw "Bla-bla";
  }).toThrowErrorMatchingInlineSnapshot('"Bla-bla"');
});

// fails with `Error: snapshot function didn't throw`
it("doesn't throw", () => {
  expect(() => {}).not.toThrowErrorMatchingInlineSnapshot('"Bla-bla"');
});

System Info

System:
    OS: Linux 5.15 Ubuntu 22.04.2 LTS 22.04.2 LTS (Jammy Jellyfish)
    CPU: (20) x64 12th Gen Intel(R) Core(TM) i9-12900H
    Memory: 23.12 GB / 31.19 GB
    Container: Yes
    Shell: 5.1.16 - /bin/bash
  Binaries:
    Node: 18.13.0 - ~/.nvm/versions/node/v18.13.0/bin/node
    npm: 8.19.3 - ~/.nvm/versions/node/v18.13.0/bin/npm
  Browsers:
    Chrome: 111.0.5563.110
  npmPackages:
    @vitejs/plugin-vue: ^3.1.2 => 3.2.0 
    @vitejs/plugin-vue-jsx: ^1.3.9 => 1.3.10 
    @vitest/coverage-c8: ^0.29.2 => 0.29.2 
    vite: ^3.1.8 => 3.2.5 
    vitest: ^0.29.2 => 0.29.2 

Used Package Manager

npm

Validations

@Maxim-Mazurok Maxim-Mazurok changed the title .not.toThrowErrorMatchingInlineSnapshot() doesn't work .not.toThrowErrorMatchingInlineSnapshot() doesn't work as expected Mar 28, 2023
@sheremet-va sheremet-va added p3-minor-bug An edge case that only affects very specific usage (priority) and removed bug labels Feb 16, 2024
@sheremet-va
Copy link
Member

After rereading this, I am not sure it makes sense to support "not" operator. What string should it generate then? Just anything except the current value?

@sheremet-va
Copy link
Member

Closed by #5294

@github-actions github-actions bot locked and limited conversation to collaborators Mar 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
Archived in project
Development

No branches or pull requests

2 participants