@quickpickle/vitest-browser 0.1.0 → 0.2.0
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/CHANGELOG.md +11 -0
- package/README.md +3 -2
- package/dist/VitestBrowserWorld.cjs +64 -16
- package/dist/VitestBrowserWorld.cjs.map +1 -1
- package/dist/VitestBrowserWorld.d.ts +16 -18
- package/dist/VitestBrowserWorld.mjs +65 -17
- package/dist/VitestBrowserWorld.mjs.map +1 -1
- package/dist/actions.steps.cjs +2 -2
- package/dist/actions.steps.cjs.map +1 -1
- package/dist/actions.steps.mjs +2 -2
- package/dist/actions.steps.mjs.map +1 -1
- package/dist/frameworks/ReactBrowserWorld.cjs +2 -0
- package/dist/frameworks/ReactBrowserWorld.cjs.map +1 -1
- package/dist/frameworks/ReactBrowserWorld.mjs +2 -0
- package/dist/frameworks/ReactBrowserWorld.mjs.map +1 -1
- package/dist/frameworks/SvelteBrowserWorld.cjs +2 -0
- package/dist/frameworks/SvelteBrowserWorld.cjs.map +1 -1
- package/dist/frameworks/SvelteBrowserWorld.mjs +2 -0
- package/dist/frameworks/SvelteBrowserWorld.mjs.map +1 -1
- package/dist/frameworks/VueBrowserWorld.cjs +2 -0
- package/dist/frameworks/VueBrowserWorld.cjs.map +1 -1
- package/dist/frameworks/VueBrowserWorld.mjs +2 -0
- package/dist/frameworks/VueBrowserWorld.mjs.map +1 -1
- package/dist/frameworks/react.cjs +2 -0
- package/dist/frameworks/react.cjs.map +1 -1
- package/dist/frameworks/react.mjs +2 -0
- package/dist/frameworks/react.mjs.map +1 -1
- package/dist/frameworks/svelte.cjs +2 -0
- package/dist/frameworks/svelte.cjs.map +1 -1
- package/dist/frameworks/svelte.mjs +2 -0
- package/dist/frameworks/svelte.mjs.map +1 -1
- package/dist/frameworks/vue.cjs +2 -0
- package/dist/frameworks/vue.cjs.map +1 -1
- package/dist/frameworks/vue.mjs +2 -0
- package/dist/frameworks/vue.mjs.map +1 -1
- package/dist/outcomes.steps.cjs +4 -22
- package/dist/outcomes.steps.cjs.map +1 -1
- package/dist/outcomes.steps.mjs +4 -22
- package/dist/outcomes.steps.mjs.map +1 -1
- package/package.json +5 -4
- package/rollup.config.js +1 -0
- package/src/VitestBrowserWorld.ts +80 -25
- package/src/actions.steps.ts +2 -2
- package/src/outcomes.steps.ts +4 -22
- package/tests/generic/browser-actions.feature +5 -5
- package/tests/generic/browser-generic.feature +16 -19
- package/tests/generic/generic.steps.ts +6 -2
- package/vitest.workspace.ts +30 -27
package/src/outcomes.steps.ts
CHANGED
|
@@ -232,34 +232,16 @@ Then('a/an/the (value of )(the ){string} {word} should not/NOT be/equal {int}',
|
|
|
232
232
|
|
|
233
233
|
// Visual regression testing
|
|
234
234
|
Then('(the )screenshot/snapshot should match', async function (world:VitestBrowserWorld) {
|
|
235
|
-
await
|
|
236
|
-
...world.worldConfig.screenshotOptions,
|
|
237
|
-
customSnapshotsDir: world.screenshotDir,
|
|
238
|
-
customSnapshotIdentifier: world.screenshotFilename,
|
|
239
|
-
})
|
|
235
|
+
await world.expectScreenshotMatch(world.page)
|
|
240
236
|
})
|
|
241
237
|
Then('(the )screenshot/snapshot {string} should match', async function (world:VitestBrowserWorld, name:string) {
|
|
242
|
-
|
|
243
|
-
await expect(world.page).toMatchImageSnapshot({
|
|
244
|
-
...world.worldConfig.screenshotOptions,
|
|
245
|
-
customSnapshotsDir: world.screenshotDir,
|
|
246
|
-
customSnapshotIdentifier: `${name}${explodedTags}`,
|
|
247
|
-
})
|
|
238
|
+
await world.expectScreenshotMatch(world.page, name)
|
|
248
239
|
})
|
|
249
240
|
Then('(the )screenshot/snapshot of the {string} {word} should match', async function (world:VitestBrowserWorld, identifier, role) {
|
|
250
241
|
let locator = await world.getLocator(world.page, identifier, role)
|
|
251
|
-
await
|
|
252
|
-
...world.worldConfig.screenshotOptions,
|
|
253
|
-
customSnapshotsDir: world.screenshotDir,
|
|
254
|
-
customSnapshotIdentifier: world.screenshotFilename,
|
|
255
|
-
})
|
|
242
|
+
await world.expectScreenshotMatch(locator)
|
|
256
243
|
})
|
|
257
244
|
Then('(the )screenshot/snapshot {string} of the {string} {word} should match', async function (world:VitestBrowserWorld, name, identifier, role) {
|
|
258
245
|
let locator = await world.getLocator(world.page, identifier, role)
|
|
259
|
-
|
|
260
|
-
await expect(locator).toMatchImageSnapshot({
|
|
261
|
-
...world.worldConfig.screenshotOptions,
|
|
262
|
-
customSnapshotsDir: world.screenshotDir,
|
|
263
|
-
customSnapshotIdentifier: `${name}${explodedTags}`,
|
|
264
|
-
})
|
|
246
|
+
await world.expectScreenshotMatch(locator, name)
|
|
265
247
|
})
|
|
@@ -168,7 +168,7 @@ Feature: Actions step definitions in Vitest Browser
|
|
|
168
168
|
|
|
169
169
|
Scenario: Taking a default screenshot
|
|
170
170
|
When I take a screenshot
|
|
171
|
-
Then the screenshot "Actions step definitions in Vitest Browser_Taking a default screenshot_01.png" should exist--delete it
|
|
171
|
+
Then the screenshot "Feature Actions step definitions in Vitest Browser_Taking a default screenshot_01.png" should exist--delete it
|
|
172
172
|
|
|
173
173
|
Scenario: Taking a named screenshot
|
|
174
174
|
When I take a screenshot named "pickles"
|
|
@@ -184,10 +184,10 @@ Feature: Actions step definitions in Vitest Browser
|
|
|
184
184
|
|
|
185
185
|
@sequential
|
|
186
186
|
Scenario: Cleaning up the screenshots with exploded tags
|
|
187
|
-
Then the screenshot "Actions step definitions in Vitest Browser_Taking a default screenshot with exploded tags (sequential,tag1)_01.png" should exist--delete it
|
|
188
|
-
And the screenshot "Actions step definitions in Vitest Browser_Taking a default screenshot with exploded tags (sequential,tag2)_01.png" should exist--delete it
|
|
187
|
+
Then the screenshot "Feature Actions step definitions in Vitest Browser_Taking a default screenshot with exploded tags (sequential,tag1)_01.png" should exist--delete it
|
|
188
|
+
And the screenshot "Feature Actions step definitions in Vitest Browser_Taking a default screenshot with exploded tags (sequential,tag2)_01.png" should exist--delete it
|
|
189
189
|
|
|
190
190
|
@sequential @skip-ci
|
|
191
191
|
Scenario: Cleaning up the screenshots with exploded tags
|
|
192
|
-
And the screenshot "
|
|
193
|
-
And the screenshot "
|
|
192
|
+
And the screenshot "temp_(sequential,tag1).png" should exist--delete it
|
|
193
|
+
And the screenshot "temp_(sequential,tag2).png" should exist--delete it
|
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
@todo
|
|
2
1
|
Feature: Basic tests of Vitest Browser Mode and steps
|
|
3
2
|
|
|
3
|
+
Background:
|
|
4
|
+
Given I render the "Example" component
|
|
5
|
+
|
|
4
6
|
@skip-ci
|
|
5
7
|
Rule: Visual regression testing must be supported
|
|
6
8
|
|
|
7
9
|
Example: Passing visual regression test
|
|
8
|
-
When I render the "Example" component
|
|
9
10
|
Then the screenshot should match
|
|
10
11
|
|
|
11
12
|
Example: Passing named visual regression test
|
|
12
|
-
When I render the "Example" component
|
|
13
13
|
Then the screenshot "visual-regression-example-page" should match
|
|
14
14
|
|
|
15
15
|
Example: Passing visual regression test of an element
|
|
16
|
-
When I render the "Example" component
|
|
17
16
|
Then the screenshot of the "XKCD Comic" img should match
|
|
18
17
|
|
|
18
|
+
@todo
|
|
19
19
|
Example: Passing named visual regression test of an element
|
|
20
|
-
When I render the "Example" component
|
|
21
20
|
Then the screenshot "visual-regression-faq-section" of the "#faq" element should match
|
|
22
21
|
|
|
23
|
-
@
|
|
22
|
+
@soft
|
|
24
23
|
Example: Failing visual regression test
|
|
25
|
-
When I
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
And the screenshot "
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
And the screenshot "
|
|
24
|
+
When I take a screenshot of the "Image" link named "made-to-fail"
|
|
25
|
+
And I take a screenshot of the "FAQ" link named "faq"
|
|
26
|
+
Then the screenshot "made-to-fail.png.diff.png" should not exist
|
|
27
|
+
And the screenshot "made-to-fail.png.actual.png" should not exist
|
|
28
|
+
And the screenshot "made-to-fail" of the "FAQ" link should match
|
|
29
|
+
Then the screenshot "made-to-fail.png.diff.png" should not exist
|
|
30
|
+
And the screenshot "made-to-fail.png.actual.png" should exist--delete it
|
|
31
|
+
And the screenshot "faq.png" should exist--delete it
|
|
32
|
+
And the screenshot "made-to-fail.png" should exist--delete it
|
|
33
|
+
Then there should have been 1 error
|
|
33
34
|
|
|
34
35
|
@todo
|
|
35
36
|
Rule: Setting screenshot options must be supported
|
|
36
37
|
|
|
37
38
|
Scenario: Setting a screenshot mask
|
|
38
|
-
Given I render the "Example" component
|
|
39
39
|
And the following world config:
|
|
40
40
|
```yaml
|
|
41
41
|
screenshotOptions:
|
|
@@ -45,7 +45,6 @@ Feature: Basic tests of Vitest Browser Mode and steps
|
|
|
45
45
|
Then the screenshot should match
|
|
46
46
|
|
|
47
47
|
Scenario: Setting a clip area
|
|
48
|
-
Given I render the "Example" component
|
|
49
48
|
And the following world config:
|
|
50
49
|
```yaml
|
|
51
50
|
screenshotOptions:
|
|
@@ -68,12 +67,10 @@ Feature: Basic tests of Vitest Browser Mode and steps
|
|
|
68
67
|
Then the screenshot "test.png" should exist--delete it
|
|
69
68
|
|
|
70
69
|
Scenario: Taking a screenshot of an element
|
|
71
|
-
Given I load the file "tests/examples/example.html"
|
|
72
70
|
When I take a screenshot of the "Image" link
|
|
73
|
-
Then the screenshot "Feature Basic tests of Vitest Browser Mode and steps_Taking a screenshot of an
|
|
71
|
+
Then the screenshot "Feature Basic tests of Vitest Browser Mode and steps_Taking a screenshot of an element_01.png" should exist--delete it
|
|
74
72
|
|
|
75
73
|
Scenario: Taking a named screenshot of an element
|
|
76
|
-
Given I load the file "tests/examples/example.html"
|
|
77
74
|
When I take a screenshot of the "XKCD Comic" img named "test2"
|
|
78
75
|
Then the screenshot "test2.png" should exist--delete it
|
|
79
76
|
|
|
@@ -14,10 +14,14 @@ Then('the screenshot {string} should exist(--delete it)', async function (world:
|
|
|
14
14
|
Then('the screenshot {string} should not exist', async function (world:VitestBrowserWorld, filepath:string) {
|
|
15
15
|
let fullpath = world.fullPath(`${world.screenshotDir}/${filepath}`)
|
|
16
16
|
try {
|
|
17
|
-
await
|
|
17
|
+
await commands.readFile(fullpath);
|
|
18
18
|
throw new Error(`Screenshot ${filepath} should not exist`)
|
|
19
19
|
}
|
|
20
20
|
catch(e) {
|
|
21
|
-
if (e.message
|
|
21
|
+
if (!e.message.match(/ENOENT/i)) throw e
|
|
22
22
|
}
|
|
23
23
|
})
|
|
24
|
+
Then('there should have been {int} error(s)', async (world:VitestBrowserWorld, int:number) => {
|
|
25
|
+
expect(world.info.errors.length).toBe(int)
|
|
26
|
+
world.info.errors = []
|
|
27
|
+
})
|
package/vitest.workspace.ts
CHANGED
|
@@ -17,6 +17,7 @@ export default [
|
|
|
17
17
|
quickpickle: {
|
|
18
18
|
worldConfig: {
|
|
19
19
|
componentDir: 'tests/svelte',
|
|
20
|
+
screenshotDir: 'tests/svelte/screenshots',
|
|
20
21
|
}
|
|
21
22
|
},
|
|
22
23
|
environment: 'browser',
|
|
@@ -33,33 +34,34 @@ export default [
|
|
|
33
34
|
}
|
|
34
35
|
}
|
|
35
36
|
},
|
|
36
|
-
{
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
37
|
+
// {
|
|
38
|
+
// name: 'react',
|
|
39
|
+
// extends: 'vite.config.ts',
|
|
40
|
+
// plugins: [react()],
|
|
41
|
+
// test: {
|
|
42
|
+
// name: 'react',
|
|
43
|
+
// include: [ 'tests/react/*.feature' ],
|
|
44
|
+
// setupFiles: [ 'src/frameworks/react.ts', 'src/actions.steps.ts', 'src/outcomes.steps.ts' ],
|
|
45
|
+
// quickpickle: {
|
|
46
|
+
// worldConfig: {
|
|
47
|
+
// componentDir: 'tests/react',
|
|
48
|
+
// screenshotDir: 'tests/react/screenshots',
|
|
49
|
+
// }
|
|
50
|
+
// },
|
|
51
|
+
// environment: 'browser',
|
|
52
|
+
// browser: {
|
|
53
|
+
// enabled: true,
|
|
54
|
+
// screenshotFailures: false,
|
|
55
|
+
// name: 'chromium',
|
|
56
|
+
// provider: 'playwright',
|
|
57
|
+
// ui: showBrowser,
|
|
58
|
+
// headless: !showBrowser,
|
|
59
|
+
// instances: [
|
|
60
|
+
// { browser:'chromium' },
|
|
61
|
+
// ]
|
|
62
|
+
// }
|
|
63
|
+
// }
|
|
64
|
+
// },
|
|
63
65
|
{
|
|
64
66
|
name: 'vue',
|
|
65
67
|
extends: 'vite.config.ts',
|
|
@@ -71,6 +73,7 @@ export default [
|
|
|
71
73
|
quickpickle: {
|
|
72
74
|
worldConfig: {
|
|
73
75
|
componentDir: 'tests/vue',
|
|
76
|
+
screenshotDir: 'tests/vue/screenshots',
|
|
74
77
|
}
|
|
75
78
|
},
|
|
76
79
|
environment: 'browser',
|