@snapvisor/storybook 6.1.8 → 7.0.1
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/LICENSE +8 -8
- package/README.md +66 -66
- package/dist/test-runner.cjs +5 -5
- package/dist/test-runner.d.mts +1 -1
- package/dist/test-runner.mjs +5 -5
- package/dist/vitest-plugin.d.mts +3 -3
- package/dist/vitest-plugin.mjs +6 -6
- package/dist/vitest-setup-file.mjs +1 -1
- package/dist/vitest.d.mts +2 -2
- package/dist/vitest.mjs +2 -2
- package/package.json +9 -9
package/LICENSE
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
Copyright 2026 Devino Solutions Inc. (Snapvisor modifications)
|
|
2
|
-
Copyright 2022 Smooth Code
|
|
3
|
-
|
|
4
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
5
|
-
|
|
6
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
7
|
-
|
|
8
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
1
|
+
Copyright 2026 Devino Solutions Inc. (Snapvisor modifications)
|
|
2
|
+
Copyright 2022 Smooth Code
|
|
3
|
+
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
5
|
+
|
|
6
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
7
|
+
|
|
8
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
<p align="center">
|
|
2
|
-
<a href="https://argos-ci.com/?utm_source=github&utm_medium=logo" target="_blank">
|
|
3
|
-
<picture>
|
|
4
|
-
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/argos-ci/argos/main/resources/logos/github-readme-logo-dark.png">
|
|
5
|
-
<img alt="Argos" src="https://raw.githubusercontent.com/argos-ci/argos/main/resources/logos/github-readme-logo-light.png" width="360" height="70">
|
|
6
|
-
</picture>
|
|
7
|
-
</a>
|
|
8
|
-
</p>
|
|
9
|
-
|
|
10
|
-
<p align="center"><strong>The open source visual testing platform for AI-native engineering teams.</strong></p>
|
|
11
|
-
|
|
12
|
-
# Official Argos Storybook integration
|
|
13
|
-
|
|
14
|
-
[](https://www.npmjs.com/package/@snapvisor/storybook)
|
|
15
|
-
[](https://www.npmjs.com/package/@snapvisor/storybook)
|
|
16
|
-
[](https://www.npmjs.com/package/@snapvisor/storybook)
|
|
17
|
-
|
|
18
|
-
Capture and review visual changes of your [Storybook](https://storybook.js.org/) stories with Argos. It runs your stories in a real browser and uploads a screenshot of each one to Argos in your CI.
|
|
19
|
-
|
|
20
|
-
Visit the [Storybook SDK documentation](https://argos-ci.com/docs/reference/storybook) for guides, the API reference, and more.
|
|
21
|
-
|
|
22
|
-
## Installation
|
|
23
|
-
|
|
24
|
-
```sh
|
|
25
|
-
npm install --save-dev @snapvisor/storybook
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
## Usage
|
|
29
|
-
|
|
30
|
-
The recommended way to run visual tests is with the [Storybook Vitest addon](https://storybook.js.org/docs/writing-tests/integrations/vitest-addon). Register the Argos plugin in your Vitest config:
|
|
31
|
-
|
|
32
|
-
```ts
|
|
33
|
-
// vitest.config.ts
|
|
34
|
-
import { defineConfig } from "vitest/config";
|
|
35
|
-
import { argosVitestPlugin } from "@snapvisor/storybook/vitest-plugin";
|
|
36
|
-
|
|
37
|
-
export default defineConfig({
|
|
38
|
-
plugins: [
|
|
39
|
-
argosVitestPlugin({
|
|
40
|
-
// Upload the screenshots to Argos only on CI.
|
|
41
|
-
uploadToArgos: process.env.CI === "true",
|
|
42
|
-
}),
|
|
43
|
-
],
|
|
44
|
-
});
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
A screenshot is captured for every story automatically. To capture additional screenshots (for example, at different steps of an interaction), call `argosScreenshot` inside a story's `play` function:
|
|
48
|
-
|
|
49
|
-
```ts
|
|
50
|
-
// Button.stories.tsx
|
|
51
|
-
import { argosScreenshot } from "@snapvisor/storybook/vitest";
|
|
52
|
-
|
|
53
|
-
export const Example: Story = {
|
|
54
|
-
play: async (ctx) => {
|
|
55
|
-
await argosScreenshot(ctx, "example");
|
|
56
|
-
},
|
|
57
|
-
};
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
> Using the [Storybook Test Runner](https://storybook.js.org/docs/writing-tests/integrations/test-runner) instead? Import `argosScreenshot` from `@snapvisor/storybook/test-runner` and call it from the `postVisit` hook. See the [Test Runner quickstart](https://argos-ci.com/docs/quickstart/storybook-quickstart/storybook-test-runner-quickstart).
|
|
61
|
-
|
|
62
|
-
## Links
|
|
63
|
-
|
|
64
|
-
- [Official SDK Docs](https://argos-ci.com/docs/reference/storybook)
|
|
65
|
-
- [Quickstart](https://argos-ci.com/docs/quickstart/storybook-quickstart)
|
|
66
|
-
- [Discord](https://argos-ci.com/discord)
|
|
1
|
+
<p align="center">
|
|
2
|
+
<a href="https://argos-ci.com/?utm_source=github&utm_medium=logo" target="_blank">
|
|
3
|
+
<picture>
|
|
4
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/argos-ci/argos/main/resources/logos/github-readme-logo-dark.png">
|
|
5
|
+
<img alt="Argos" src="https://raw.githubusercontent.com/argos-ci/argos/main/resources/logos/github-readme-logo-light.png" width="360" height="70">
|
|
6
|
+
</picture>
|
|
7
|
+
</a>
|
|
8
|
+
</p>
|
|
9
|
+
|
|
10
|
+
<p align="center"><strong>The open source visual testing platform for AI-native engineering teams.</strong></p>
|
|
11
|
+
|
|
12
|
+
# Official Argos Storybook integration
|
|
13
|
+
|
|
14
|
+
[](https://www.npmjs.com/package/@snapvisor/storybook)
|
|
15
|
+
[](https://www.npmjs.com/package/@snapvisor/storybook)
|
|
16
|
+
[](https://www.npmjs.com/package/@snapvisor/storybook)
|
|
17
|
+
|
|
18
|
+
Capture and review visual changes of your [Storybook](https://storybook.js.org/) stories with Argos. It runs your stories in a real browser and uploads a screenshot of each one to Argos in your CI.
|
|
19
|
+
|
|
20
|
+
Visit the [Storybook SDK documentation](https://argos-ci.com/docs/reference/storybook) for guides, the API reference, and more.
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
npm install --save-dev @snapvisor/storybook
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
The recommended way to run visual tests is with the [Storybook Vitest addon](https://storybook.js.org/docs/writing-tests/integrations/vitest-addon). Register the Argos plugin in your Vitest config:
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
// vitest.config.ts
|
|
34
|
+
import { defineConfig } from "vitest/config";
|
|
35
|
+
import { argosVitestPlugin } from "@snapvisor/storybook/vitest-plugin";
|
|
36
|
+
|
|
37
|
+
export default defineConfig({
|
|
38
|
+
plugins: [
|
|
39
|
+
argosVitestPlugin({
|
|
40
|
+
// Upload the screenshots to Argos only on CI.
|
|
41
|
+
uploadToArgos: process.env.CI === "true",
|
|
42
|
+
}),
|
|
43
|
+
],
|
|
44
|
+
});
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
A screenshot is captured for every story automatically. To capture additional screenshots (for example, at different steps of an interaction), call `argosScreenshot` inside a story's `play` function:
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
// Button.stories.tsx
|
|
51
|
+
import { argosScreenshot } from "@snapvisor/storybook/vitest";
|
|
52
|
+
|
|
53
|
+
export const Example: Story = {
|
|
54
|
+
play: async (ctx) => {
|
|
55
|
+
await argosScreenshot(ctx, "example");
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
> Using the [Storybook Test Runner](https://storybook.js.org/docs/writing-tests/integrations/test-runner) instead? Import `argosScreenshot` from `@snapvisor/storybook/test-runner` and call it from the `postVisit` hook. See the [Test Runner quickstart](https://argos-ci.com/docs/quickstart/storybook-quickstart/storybook-test-runner-quickstart).
|
|
61
|
+
|
|
62
|
+
## Links
|
|
63
|
+
|
|
64
|
+
- [Official SDK Docs](https://argos-ci.com/docs/reference/storybook)
|
|
65
|
+
- [Quickstart](https://argos-ci.com/docs/quickstart/storybook-quickstart)
|
|
66
|
+
- [Discord](https://argos-ci.com/discord)
|
package/dist/test-runner.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const argosScreenshot = async (...args) => {
|
|
2
|
-
const { argosScreenshot } = await import("./test-runner.mjs");
|
|
3
|
-
return argosScreenshot(...args);
|
|
4
|
-
};
|
|
5
|
-
exports.argosScreenshot = argosScreenshot;
|
|
1
|
+
const argosScreenshot = async (...args) => {
|
|
2
|
+
const { argosScreenshot } = await import("./test-runner.mjs");
|
|
3
|
+
return argosScreenshot(...args);
|
|
4
|
+
};
|
|
5
|
+
exports.argosScreenshot = argosScreenshot;
|
package/dist/test-runner.d.mts
CHANGED
package/dist/test-runner.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { readVersionFromPackage } from "@snapvisor/util";
|
|
|
5
5
|
//#region src/utils/metadata.ts
|
|
6
6
|
const require = createRequire(import.meta.url);
|
|
7
7
|
/**
|
|
8
|
-
* Get the version of the
|
|
8
|
+
* Get the version of the Snapvisor Playwright SDK.
|
|
9
9
|
*/
|
|
10
10
|
async function getArgosStorybookVersion() {
|
|
11
11
|
return readVersionFromPackage(require.resolve("@snapvisor/storybook/package.json"));
|
|
@@ -74,7 +74,7 @@ function getViewport(parameters, viewportName) {
|
|
|
74
74
|
return null;
|
|
75
75
|
}
|
|
76
76
|
/**
|
|
77
|
-
* Get the
|
|
77
|
+
* Get the Snapvisor parameters from the Storybook context.
|
|
78
78
|
*/
|
|
79
79
|
function getArgosParameters(parameters) {
|
|
80
80
|
if ("argos" in parameters && parameters.argos && typeof parameters.argos === "object") return parameters.argos;
|
|
@@ -104,10 +104,10 @@ function getFitToContentFromParameters(parameters) {
|
|
|
104
104
|
async function storybookArgosScreenshot(handler, context, options) {
|
|
105
105
|
const argosOptions = {
|
|
106
106
|
...options,
|
|
107
|
-
stabilize: options?.stabilize
|
|
107
|
+
stabilize: typeof options?.stabilize === "object" ? {
|
|
108
108
|
waitForAriaBusy: false,
|
|
109
|
-
...
|
|
110
|
-
}
|
|
109
|
+
...options.stabilize
|
|
110
|
+
} : options?.stabilize ?? { waitForAriaBusy: false }
|
|
111
111
|
};
|
|
112
112
|
const version = await getArgosStorybookVersion();
|
|
113
113
|
const storyUrl = `http://localhost:6006/?path=/story/${context.story.id}`;
|
package/dist/vitest-plugin.d.mts
CHANGED
|
@@ -40,13 +40,13 @@ type ArgosScreenshotOptions = Omit<ArgosScreenshotOptions$1, "viewports">;
|
|
|
40
40
|
type ArgosScreenshotCommandArgs = [Pick<StorybookScreenshotContext<Frame>, "name" | "story" | "test" | "mode">];
|
|
41
41
|
interface ArgosVitestPluginOptions extends ArgosReporterConfig, ArgosScreenshotOptions {
|
|
42
42
|
/**
|
|
43
|
-
* Upload the report to
|
|
44
|
-
* @default
|
|
43
|
+
* Upload the report to Snapvisor.
|
|
44
|
+
* @default false
|
|
45
45
|
*/
|
|
46
46
|
uploadToArgos?: boolean;
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
|
-
* Create a command for taking
|
|
49
|
+
* Create a command for taking Snapvisor screenshots in Vitest.
|
|
50
50
|
*/
|
|
51
51
|
declare const createArgosScreenshotCommand: (pluginOptions?: ArgosVitestPluginOptions) => BrowserCommand<ArgosScreenshotCommandArgs>;
|
|
52
52
|
declare function argosVitestPlugin(options?: ArgosVitestPluginOptions): Plugin;
|
package/dist/vitest-plugin.mjs
CHANGED
|
@@ -8,7 +8,7 @@ import { fileURLToPath } from "node:url";
|
|
|
8
8
|
//#region src/utils/metadata.ts
|
|
9
9
|
const require = createRequire(import.meta.url);
|
|
10
10
|
/**
|
|
11
|
-
* Get the version of the
|
|
11
|
+
* Get the version of the Snapvisor Playwright SDK.
|
|
12
12
|
*/
|
|
13
13
|
async function getArgosStorybookVersion() {
|
|
14
14
|
return readVersionFromPackage(require.resolve("@snapvisor/storybook/package.json"));
|
|
@@ -61,7 +61,7 @@ function getViewport(parameters, viewportName) {
|
|
|
61
61
|
return null;
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
64
|
-
* Get the
|
|
64
|
+
* Get the Snapvisor parameters from the Storybook context.
|
|
65
65
|
*/
|
|
66
66
|
function getArgosParameters(parameters) {
|
|
67
67
|
if ("argos" in parameters && parameters.argos && typeof parameters.argos === "object") return parameters.argos;
|
|
@@ -91,10 +91,10 @@ function getFitToContentFromParameters(parameters) {
|
|
|
91
91
|
async function storybookArgosScreenshot(handler, context, options) {
|
|
92
92
|
const argosOptions = {
|
|
93
93
|
...options,
|
|
94
|
-
stabilize: options?.stabilize
|
|
94
|
+
stabilize: typeof options?.stabilize === "object" ? {
|
|
95
95
|
waitForAriaBusy: false,
|
|
96
|
-
...
|
|
97
|
-
}
|
|
96
|
+
...options.stabilize
|
|
97
|
+
} : options?.stabilize ?? { waitForAriaBusy: false }
|
|
98
98
|
};
|
|
99
99
|
const version = await getArgosStorybookVersion();
|
|
100
100
|
const storyUrl = `http://localhost:6006/?path=/story/${context.story.id}`;
|
|
@@ -243,7 +243,7 @@ function composeName(name, suffix) {
|
|
|
243
243
|
//#endregion
|
|
244
244
|
//#region src/vitest-plugin.ts
|
|
245
245
|
/**
|
|
246
|
-
* Create a command for taking
|
|
246
|
+
* Create a command for taking Snapvisor screenshots in Vitest.
|
|
247
247
|
*/
|
|
248
248
|
const createArgosScreenshotCommand = (pluginOptions) => {
|
|
249
249
|
const screenshotOptions = pluginOptions ?? {};
|
package/dist/vitest.d.mts
CHANGED
|
@@ -43,13 +43,13 @@ declare module "vitest/browser" {
|
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
46
|
-
* Setup
|
|
46
|
+
* Setup Snapvisor hooks for Vitest.
|
|
47
47
|
*/
|
|
48
48
|
declare function setupArgos(api: {
|
|
49
49
|
afterEach: typeof vitest.afterEach;
|
|
50
50
|
}): void;
|
|
51
51
|
/**
|
|
52
|
-
* Take an
|
|
52
|
+
* Take an Snapvisor screenshot of a story in Vitest.
|
|
53
53
|
*/
|
|
54
54
|
declare function argosScreenshot(story: {
|
|
55
55
|
parameters: Record<string, any>;
|
package/dist/vitest.mjs
CHANGED
|
@@ -18,7 +18,7 @@ function hasPlay(storyContext) {
|
|
|
18
18
|
//#endregion
|
|
19
19
|
//#region src/vitest.ts
|
|
20
20
|
/**
|
|
21
|
-
* Setup
|
|
21
|
+
* Setup Snapvisor hooks for Vitest.
|
|
22
22
|
*/
|
|
23
23
|
function setupArgos(api) {
|
|
24
24
|
api.afterEach(async (ctx) => {
|
|
@@ -50,7 +50,7 @@ function setupArgos(api) {
|
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
52
|
/**
|
|
53
|
-
* Take an
|
|
53
|
+
* Take an Snapvisor screenshot of a story in Vitest.
|
|
54
54
|
*/
|
|
55
55
|
async function argosScreenshot(story, name) {
|
|
56
56
|
if (!await checkIsVitestEnv()) return;
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@snapvisor/storybook",
|
|
3
3
|
"description": "Visual testing for Storybook test runner.",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "7.0.1",
|
|
5
5
|
"author": "Smooth Code",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "https://github.com/
|
|
9
|
+
"url": "git+https://github.com/DevinoSolutions/snapvisor-js.git",
|
|
10
10
|
"directory": "packages/storybook"
|
|
11
11
|
},
|
|
12
|
-
"homepage": "https://
|
|
12
|
+
"homepage": "https://snapvisor.io/docs",
|
|
13
13
|
"keywords": [
|
|
14
14
|
"storybook",
|
|
15
15
|
"storybook-addon",
|
|
@@ -49,13 +49,13 @@
|
|
|
49
49
|
"node": ">=22.0.0"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@snapvisor/core": "
|
|
53
|
-
"@snapvisor/playwright": "
|
|
54
|
-
"@snapvisor/util": "
|
|
55
|
-
"@snapvisor/vitest": "0.
|
|
52
|
+
"@snapvisor/core": "7.0.0",
|
|
53
|
+
"@snapvisor/playwright": "8.0.0",
|
|
54
|
+
"@snapvisor/util": "5.0.0",
|
|
55
|
+
"@snapvisor/vitest": "0.4.0"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@snapvisor/cli": "
|
|
58
|
+
"@snapvisor/cli": "7.0.0",
|
|
59
59
|
"@snapvisor/util": "workspace:*",
|
|
60
60
|
"@storybook/addon-docs": "^10.4.6",
|
|
61
61
|
"@storybook/addon-links": "^10.4.6",
|
|
@@ -100,5 +100,5 @@
|
|
|
100
100
|
"check-format": "prettier --check --ignore-unknown --ignore-path=./.gitignore --ignore-path=../../.gitignore --ignore-path=../../.prettierignore .",
|
|
101
101
|
"lint": "eslint ."
|
|
102
102
|
},
|
|
103
|
-
"gitHead": "
|
|
103
|
+
"gitHead": "c755c5695739eb6f453969ea02babb317425ba45"
|
|
104
104
|
}
|