fix(snapshot): fail test when snapshot assertion is used with test.fails#10090
Conversation
✅ Deploy Preview for vitest-dev ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
…ed-with-test-fails
This comment was marked as resolved.
This comment was marked as resolved.
I'm not so sure it's a breaking change. What kind of use cases does this break? |
I removed one test from |
Oh, I don't think this PR fixes the issue then. I think |
|
Why? The test can have other assertions that fail, and snapshot to pass: test.fails('test', () => {
expect(shape).toMatchInlineSnapshot(`{ name: 'Alice' }`)
expect(otherShape).toEqual({ name: 'Bob' }) // fails!
})It should just ignore the snapshot error when test.fails('test', () => {
expect(shape).toMatchInlineSnapshot(`{ name: 'Bob' }`) // fails
})
vitest run -u // should ignore the error in `test.fails`, treat as --update=none in that test |
|
The reason to prefer reject everything is because supporting the case by case can be confusing when users end up reaching such invalid state during the development without directly modifying the test itself to introduce forbidden combination of |
Description
it.fails#9495expect.softhandling is a bit annoying 🤔 I ended up with usingerror.__vitest_test_syntax_error__to allow communicate between expect/runner/vitest packages basically.This is likely a breaking change since users can do really weird thing with snapshot.
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
pnpm-lock.yamlunless you introduce a new test example.Tests
pnpm test:ci.Documentation
pnpm run docscommand.Changesets
feat:,fix:,perf:,docs:, orchore:.