generated from ample/next-starter-ample
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstoryshots.test.js
37 lines (27 loc) · 999 Bytes
/
storyshots.test.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
// ---------------------------------------------------------
import initStoryshots, {
Stories2SnapsConverter,
} from '@storybook/addon-storyshots'
import wait from 'waait'
import { act, create } from 'react-test-renderer'
import { createElement } from 'react'
// ---------------------------------------------------------
const converter = new Stories2SnapsConverter()
// ---------------------------------------------------------
initStoryshots({
asyncJest: true,
configPath: './.config/.storybook',
integrityOptions: { cwd: __dirname },
test: async ({ context, done, story }) => {
let renderer
act(() => {
renderer = create(createElement(story.render))
})
// -------------------------------------------------------
await act(() => wait(0))
// -------------------------------------------------------
const snapshotFileName = converter.getSnapshotFileName(context)
expect(renderer).toMatchSpecificSnapshot(snapshotFileName)
done()
},
})