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

Snapshot generated by toMatchSnapshot("...") are considered obsolete for skipped tests #7113

Open
6 tasks done
hi-ogawa opened this issue Dec 22, 2024 · 0 comments · May be fixed by #7126
Open
6 tasks done

Snapshot generated by toMatchSnapshot("...") are considered obsolete for skipped tests #7113

hi-ogawa opened this issue Dec 22, 2024 · 0 comments · May be fixed by #7126
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)

Comments

@hi-ogawa
Copy link
Contributor

hi-ogawa commented Dec 22, 2024

Describe the bug

Related: #7106

import { expect, test } from 'vitest';

test('x test', () => {
  expect(0).toMatchSnapshot();
  expect(0).toMatchSnapshot();
});

// when test is skipped, `toMatchSnapshot('xxx')` are considered obsolete,
// which can happen e.g. by having `test.skip` here or `test.only` above, or test name filter etc...
test.skip('y test', () => {
  expect(0).toMatchSnapshot('foo');
  expect(0).toMatchSnapshot('bar'); 
});

We have an "obsolete protection" for auto-incremented snapshot name (x test 1 and x test 2 in this case), but this probably isn't handling for toMatchSnapshot("...") API (y test > foo and y test > bar in this case).

Reproduction

https://stackblitz.com/edit/vitest-dev-vitest-mitcgkkj?file=test%2Fbasic.test.ts

System Info

(stackblitz)

  System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 18.20.3 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.2.3 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/bin/pnpm
  npmPackages:
    @vitest/ui: latest => 2.1.8 
    vite: latest => 5.4.11 
    vitest: latest => 2.1.8

Used Package Manager

npm

Validations

@hi-ogawa hi-ogawa added pending triage p3-minor-bug An edge case that only affects very specific usage (priority) and removed pending triage labels Dec 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant