@argos-ci/storybook 0.1.2 → 0.2.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/dist/index.cjs CHANGED
@@ -1,7 +1,5 @@
1
- // @ts-ignore
2
- const argosScreenshot = async (...args)=>{
3
- // @ts-ignore
4
- const { argosScreenshot } = await import('./index.mjs');
5
- return argosScreenshot(...args);
1
+ const argosScreenshot = async (...args) => {
2
+ const { argosScreenshot } = await import("./index.js");
3
+ return argosScreenshot(...args);
6
4
  };
7
5
  exports.argosScreenshot = argosScreenshot;
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
- import { TestContext } from "@storybook/test-runner";
2
- import { ArgosScreenshotOptions as ArgosPlaywrightScreenshotOptions } from "@argos-ci/playwright";
3
- import { Page } from "playwright";
1
+ import { TestContext } from '@storybook/test-runner';
2
+ import { ArgosScreenshotOptions as ArgosScreenshotOptions$1 } from '@argos-ci/playwright';
3
+ import { Page } from 'playwright';
4
+
4
5
  type ArgosScreenshotOptions = {
5
6
  /**
6
7
  * Fit the screenshot to the content size.
@@ -18,7 +19,7 @@ type ArgosScreenshotOptions = {
18
19
  */
19
20
  zoom?: number;
20
21
  };
21
- } & ArgosPlaywrightScreenshotOptions;
22
+ } & ArgosScreenshotOptions$1;
22
23
  /**
23
24
  * Stabilize the UI and takes a screenshot of the application under test.
24
25
  *
@@ -39,4 +40,5 @@ context: TestContext,
39
40
  * Options for the screenshot.
40
41
  */
41
42
  options?: ArgosScreenshotOptions): Promise<void>;
42
- export { ArgosScreenshotOptions, argosScreenshot };
43
+
44
+ export { type ArgosScreenshotOptions, argosScreenshot };
package/dist/index.js ADDED
@@ -0,0 +1,49 @@
1
+ // src/index.ts
2
+ import { waitForPageReady } from "@storybook/test-runner";
3
+ import {
4
+ argosScreenshot as argosPlaywrightScreenshot,
5
+ DO_NOT_USE_setMetadataConfig
6
+ } from "@argos-ci/playwright";
7
+ import { join } from "node:path";
8
+
9
+ // src/metadata.ts
10
+ import { readVersionFromPackage } from "@argos-ci/util";
11
+ import { createRequire } from "node:module";
12
+ var require2 = createRequire(import.meta.url);
13
+ async function getArgosStorybookVersion() {
14
+ const pkgPath = require2.resolve("@argos-ci/storybook/package.json");
15
+ return readVersionFromPackage(pkgPath);
16
+ }
17
+
18
+ // src/index.ts
19
+ async function argosScreenshot(page, context, options) {
20
+ const { fitToContent = true, ...screenshotOptions } = options ?? {};
21
+ await waitForPageReady(page);
22
+ const fitToContentOptions = (() => {
23
+ if (options?.element || !fitToContent) {
24
+ return {};
25
+ }
26
+ const { padding = 16, zoom = 2 } = fitToContent === true ? {} : fitToContent;
27
+ return {
28
+ element: "#storybook-root",
29
+ argosCSS: `#storybook-root { padding: ${padding}px; width: fit-content; height: fit-content; zoom: ${zoom}; }` + (options?.argosCSS ?? "")
30
+ };
31
+ })();
32
+ const version = await getArgosStorybookVersion();
33
+ DO_NOT_USE_setMetadataConfig({
34
+ sdk: { name: "@argos-ci/storybook", version },
35
+ playwrightLibraries: ["@storybook/test-runner"]
36
+ });
37
+ await argosPlaywrightScreenshot(page, join(context.title, context.name), {
38
+ ...screenshotOptions,
39
+ // Disable aria-busy stabilization by default
40
+ stabilize: screenshotOptions.stabilize ?? {
41
+ ariaBusy: false,
42
+ ...typeof screenshotOptions.stabilize === "object" ? screenshotOptions.stabilize : {}
43
+ },
44
+ ...fitToContentOptions
45
+ });
46
+ }
47
+ export {
48
+ argosScreenshot
49
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@argos-ci/storybook",
3
3
  "description": "Visual testing for Storybook test runner.",
4
- "version": "0.1.2",
4
+ "version": "0.2.1",
5
5
  "author": "Smooth Code",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -29,9 +29,9 @@
29
29
  "exports": {
30
30
  ".": {
31
31
  "types": "./dist/index.d.ts",
32
+ "import": "./dist/index.js",
32
33
  "require": "./dist/index.cjs",
33
- "import": "./dist/index.mjs",
34
- "default": "./dist/index.mjs"
34
+ "default": "./dist/index.cjs"
35
35
  },
36
36
  "./package.json": "./package.json"
37
37
  },
@@ -39,15 +39,15 @@
39
39
  "node": ">=18.16.0"
40
40
  },
41
41
  "dependencies": {
42
- "@argos-ci/playwright": "3.8.1",
43
- "@argos-ci/util": "2.1.2"
42
+ "@argos-ci/playwright": "3.9.1",
43
+ "@argos-ci/util": "2.2.0"
44
44
  },
45
45
  "peerDependencies": {
46
46
  "@storybook/test-runner": "*",
47
47
  "playwright": "*"
48
48
  },
49
49
  "devDependencies": {
50
- "@argos-ci/cli": "2.4.7",
50
+ "@argos-ci/cli": "2.5.0",
51
51
  "@argos-ci/util": "workspace:*",
52
52
  "@storybook/addon-essentials": "^8.3.6",
53
53
  "@storybook/addon-interactions": "^8.3.6",
@@ -57,18 +57,17 @@
57
57
  "@storybook/react-vite": "^8.3.6",
58
58
  "@storybook/test": "^8.3.6",
59
59
  "@storybook/test-runner": "^0.19.1",
60
- "playwright": "^1.48.1",
60
+ "playwright": "^1.48.2",
61
61
  "prop-types": "^15.8.1",
62
62
  "storybook": "^8.3.6"
63
63
  },
64
64
  "scripts": {
65
- "prebuild": "rm -rf dist",
66
- "build": "rollup -c",
65
+ "build": "tsup && cp ./src/index.cjs ./dist",
67
66
  "storybook": "storybook dev -p 6006",
68
67
  "build-storybook": "storybook build",
69
68
  "test-storybook": "NODE_NO_WARNINGS=1 NODE_OPTIONS=--experimental-vm-modules test-storybook",
70
69
  "argos-upload": "pnpm exec argos upload screenshots --build-name \"argos-storybook-e2e-node-$NODE_VERSION-$OS\"",
71
70
  "e2e": "pnpm run test-storybook && pnpm run argos-upload"
72
71
  },
73
- "gitHead": "4773ee8243e047e83c46aea3432f3b4b7c27112c"
72
+ "gitHead": "2df737ab2349a7b2c4afcae71266c40902c7561c"
74
73
  }
package/dist/index.mjs DELETED
@@ -1,58 +0,0 @@
1
- import { waitForPageReady } from '@storybook/test-runner';
2
- import { DO_NOT_USE_setMetadataConfig, argosScreenshot as argosScreenshot$1 } from '@argos-ci/playwright';
3
- import { join } from 'node:path';
4
- import { readVersionFromPackage } from '@argos-ci/util';
5
- import { createRequire } from 'node:module';
6
-
7
- const require = createRequire(import.meta.url);
8
- /**
9
- * Get the version of the Argos Playwright SDK.
10
- */ async function getArgosStorybookVersion() {
11
- const pkgPath = require.resolve("@argos-ci/storybook/package.json");
12
- return readVersionFromPackage(pkgPath);
13
- }
14
-
15
- /**
16
- * Stabilize the UI and takes a screenshot of the application under test.
17
- *
18
- * @example
19
- * argosScreenshot(page, "my-screenshot")
20
- * @see https://argos-ci.com/docs/playwright#api-overview
21
- */ async function argosScreenshot(/**
22
- * Playwright `page` object.
23
- */ page, /**
24
- * Context of the test.
25
- */ context, /**
26
- * Options for the screenshot.
27
- */ options) {
28
- const { fitToContent = true, ...screenshotOptions } = options ?? {};
29
- await waitForPageReady(page);
30
- const fitToContentOptions = (()=>{
31
- if (options?.element || !fitToContent) {
32
- return {};
33
- }
34
- const { padding = 16, zoom = 2 } = fitToContent === true ? {} : fitToContent;
35
- return {
36
- element: "#storybook-root",
37
- argosCSS: `#storybook-root { padding: ${padding}px; width: fit-content; height: fit-content; zoom: ${zoom}; }` + (options?.argosCSS ?? "")
38
- };
39
- })();
40
- const version = await getArgosStorybookVersion();
41
- await DO_NOT_USE_setMetadataConfig({
42
- sdk: {
43
- name: "@argos-ci/storybook",
44
- version
45
- },
46
- playwrightLibraries: [
47
- "@storybook/test-runner",
48
- "playwright",
49
- "playwright-core"
50
- ]
51
- });
52
- await argosScreenshot$1(page, join(context.title, context.name), {
53
- ...screenshotOptions,
54
- ...fitToContentOptions
55
- });
56
- }
57
-
58
- export { argosScreenshot };