Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions guide/snapshot.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ test('snapshot', () => {
},
]

// in Jest
// Jest 中的输出格式
expect(bar).toMatchInlineSnapshot(`
Array [
Object {
Expand All @@ -223,7 +223,7 @@ test('snapshot', () => {
]
`)

// in Vitest
// Vitest 中的输出格式
expect(bar).toMatchInlineSnapshot(`
[
{
Expand Down Expand Up @@ -280,14 +280,14 @@ exports[`toThrowErrorMatchingSnapshot > hint 1`] = `[Error: error]`;
import { expect, test } from 'vitest'

test('snapshot', () => {
// in Jest and Vitest
// Jest Vitest
expect(new Error('error')).toMatchInlineSnapshot(`[Error: error]`)

// Jest snapshots `Error.message` for `Error` instance
// Vitest prints the same value as toMatchInlineSnapshot
// Jest 会对 `Error` 实例的 `Error.message` 生成快照
// Vitest 则会输出与 toMatchInlineSnapshot 相同的值
expect(() => {
throw new Error('error')
}).toThrowErrorMatchingInlineSnapshot(`"error"`) // [!code --]
}).toThrowErrorMatchingInlineSnapshot(`[Error: error]`) // [!code ++]
}).toThrowErrorMatchingInlineSnapshot(`[Error: error]`) // [!code ++]
})
```