/
inline-test-template.js
51 lines (45 loc) · 1.35 KB
/
inline-test-template.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { describe, expect, test } from 'vitest'
// when snapshots are generated Vitest reruns `toMatchInlineSnapshot` checks
// please, don't commit generated snapshots
describe('snapshots are generated in correct order', async () => {
test('first snapshot', () => {
expect({ foo: ['bar'] }).toMatchInlineSnapshot()
})
test('second snapshot', () => {
expect({ foo: ['zed'] }).toMatchInlineSnapshot()
})
})
describe('snapshots with properties', () => {
test('without snapshot', () => {
expect({ foo: 'bar' }).toMatchInlineSnapshot({ foo: expect.any(String) })
})
test('with snapshot', () => {
expect({ first: { second: { foo: 'bar' } } }).toMatchInlineSnapshot({ first: { second: { foo: expect.any(String) } } }, `
Object {
"first": Object {
"wrong": Any<String>,
"second": null,
}
}
`)
})
test('mixed with and without snapshot', () => {
expect({ first: { second: { foo: 'bar' } } }).toMatchInlineSnapshot({ first: { second: { foo: expect.any(String) } } }, `
Object {
"first": Object {
"wrong": Any<String>,
"second": null,
}
}
`)
expect({ first: { second: { foo: 'zed' } } }).toMatchInlineSnapshot(`
Object {
"first": Object {
"second": {
"foo": "zed"
}
}
}
`)
})
})