storybook-addon-vis 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/react'
|
|
2
2
|
import { expect } from '@storybook/test'
|
|
3
|
-
import dedent from 'dedent'
|
|
4
3
|
import { page } from './@vitest/browser/context'
|
|
5
4
|
import { UNI_PNG_URL } from './testing/constants'
|
|
6
5
|
|
|
@@ -27,13 +26,12 @@ export const Failed: StoryObj = {
|
|
|
27
26
|
)
|
|
28
27
|
},
|
|
29
28
|
async play() {
|
|
30
|
-
await expect(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
})
|
|
29
|
+
await expect(page.imageSnapshot())
|
|
30
|
+
.toMatchImageSnapshot()
|
|
31
|
+
.then(
|
|
32
|
+
() => new Error('Should not reach'),
|
|
33
|
+
(error) => expect(error.message).toMatch(/Expected image to match but was differ by \d+ pixels./),
|
|
34
|
+
)
|
|
37
35
|
},
|
|
38
36
|
}
|
|
39
37
|
|
|
@@ -54,13 +52,12 @@ export const DifferentSize: StoryObj = {
|
|
|
54
52
|
},
|
|
55
53
|
async play({ canvas }) {
|
|
56
54
|
const image = await canvas.getByRole('img')
|
|
57
|
-
await expect(
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
})
|
|
55
|
+
await expect(page.imageSnapshot({ element: image }))
|
|
56
|
+
.toMatchImageSnapshot()
|
|
57
|
+
.then(
|
|
58
|
+
() => new Error('Should not reach'),
|
|
59
|
+
(error) => expect(error.message).toMatch(/Expected image to match but was differ by \d+ pixels./),
|
|
60
|
+
)
|
|
64
61
|
},
|
|
65
62
|
}
|
|
66
63
|
|
|
@@ -80,17 +77,15 @@ export const FailureThreshold: StoryObj = {
|
|
|
80
77
|
// render: () => <div data-testid="subject">unit text</div>,
|
|
81
78
|
async play({ canvas }) {
|
|
82
79
|
const subject = canvas.getByTestId('subject')
|
|
83
|
-
await expect(()
|
|
84
|
-
|
|
80
|
+
await expect(page.imageSnapshot({ element: subject }))
|
|
81
|
+
.toMatchImageSnapshot({
|
|
85
82
|
failureThreshold: 10,
|
|
86
|
-
})
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
Difference: '../__snapshots__/__diff_output__/expect.to_match_image_snapshot.stories.tsx/failure-threshold-1.png'`,
|
|
93
|
-
})
|
|
83
|
+
})
|
|
84
|
+
.then(
|
|
85
|
+
() => new Error('Should not reach'),
|
|
86
|
+
(error) =>
|
|
87
|
+
expect(error.message).toMatch(/Expected image to match within 10 pixels but was differ by \d+ pixels./),
|
|
88
|
+
)
|
|
94
89
|
},
|
|
95
90
|
}
|
|
96
91
|
|
|
@@ -99,18 +94,15 @@ export const FailureThresholdByPercentage: StoryObj = {
|
|
|
99
94
|
render: () => <div data-testid="subject">unit text</div>,
|
|
100
95
|
async play({ canvas }) {
|
|
101
96
|
const subject = canvas.getByTestId('subject')
|
|
102
|
-
await expect(()
|
|
103
|
-
|
|
97
|
+
await expect(page.imageSnapshot({ element: subject }))
|
|
98
|
+
.toMatchImageSnapshot({
|
|
104
99
|
failureThreshold: 0.1,
|
|
105
100
|
failureThresholdType: 'percent',
|
|
106
|
-
})
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
Actual: '../__snapshots__/__results__/expect.to_match_image_snapshot.stories.tsx/failure-threshold-by-percentage-1.png'
|
|
112
|
-
Difference: '../__snapshots__/__diff_output__/expect.to_match_image_snapshot.stories.tsx/failure-threshold-by-percentage-1.png'`,
|
|
113
|
-
})
|
|
101
|
+
})
|
|
102
|
+
.then(
|
|
103
|
+
() => new Error('Should not reach'),
|
|
104
|
+
(error) => expect(error.message).toMatch(/Expected image to match within 0.1% but was differ by \d+\.\d+%/),
|
|
105
|
+
)
|
|
114
106
|
},
|
|
115
107
|
}
|
|
116
108
|
|
|
@@ -131,16 +123,24 @@ export const ExactFailureThresholdByPercentage: StoryObj = {
|
|
|
131
123
|
render: () => <div data-testid="subject">unit text</div>,
|
|
132
124
|
async play({ canvas }) {
|
|
133
125
|
const subject = canvas.getByTestId('subject')
|
|
134
|
-
await expect(()
|
|
135
|
-
|
|
126
|
+
await expect(page.imageSnapshot({ element: subject }))
|
|
127
|
+
.toMatchImageSnapshot({
|
|
136
128
|
failureThresholdType: 'percent',
|
|
137
|
-
})
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
129
|
+
})
|
|
130
|
+
.then(
|
|
131
|
+
() => new Error('Should not reach'),
|
|
132
|
+
(error) => {
|
|
133
|
+
expect(error.message).toMatch(/Expected image to match but was differ by \d+\.\d+%/)
|
|
134
|
+
expect(error.message).toMatch(
|
|
135
|
+
`Expected: '../__snapshots__/expect.to_match_image_snapshot.stories.tsx/exact-failure-threshold-by-percentage-1.png'`,
|
|
136
|
+
)
|
|
137
|
+
expect(error.message).toMatch(
|
|
138
|
+
`Actual: '../__snapshots__/__results__/expect.to_match_image_snapshot.stories.tsx/exact-failure-threshold-by-percentage-1.png'`,
|
|
139
|
+
)
|
|
140
|
+
expect(error.message).toMatch(
|
|
141
|
+
`Difference: '../__snapshots__/__diff_output__/expect.to_match_image_snapshot.stories.tsx/exact-failure-threshold-by-percentage-1.png'`,
|
|
142
|
+
)
|
|
143
|
+
},
|
|
144
|
+
)
|
|
145
145
|
},
|
|
146
146
|
}
|