Skip to content

Commit

Permalink
docs: difference from jest in snapshots with custom messages (vitest-…
Browse files Browse the repository at this point in the history
  • Loading branch information
trivikr committed Feb 14, 2023
1 parent 095c639 commit 9e03f2b
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions docs/guide/snapshot.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,3 +191,26 @@ export default defineConfig({
}
})
```

#### 3. Chevron `>` is used as a separator instead of colon `:` for custom messages

Vitest uses chevron `>` as a separator instead of colon `:` for readability, when a custom message is passed during creation of a snapshot file.

For the following example test code:
```js
test('toThrowErrorMatchingSnapshot', () => {
expect(() => {
throw new Error('error')
}).toThrowErrorMatchingSnapshot('hint')
})
```

In Jest, the snapshot will be:
```console
exports[`toThrowErrorMatchingSnapshot: hint 1`] = `"error"`;
```

In Vitest, the equivalent snapshot will be:
```console
exports[`toThrowErrorMatchingSnapshot > hint 1`] = `"error"`;
```

0 comments on commit 9e03f2b

Please sign in to comment.