@chromatic-com/playwright 0.14.1 → 0.14.2-7564b53-20260519080640

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.
@@ -5,6 +5,7 @@ var child_process = require('child_process');
5
5
  var path = require('path');
6
6
  var fs = require('fs');
7
7
  var module$1 = require('module');
8
+ require('crypto');
8
9
 
9
10
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
10
11
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
@@ -20,32 +21,20 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
20
21
  return require.apply(this, arguments);
21
22
  throw Error('Dynamic require of "' + x + '" is not supported');
22
23
  });
23
- var __defProp2 = Object.defineProperty;
24
- var __name2 = /* @__PURE__ */ __name((target, value) => __defProp2(target, "name", { value, configurable: true }), "__name");
25
- var __require2 = /* @__PURE__ */ ((x) => typeof __require !== "undefined" ? __require : typeof Proxy !== "undefined" ? new Proxy(x, {
26
- get: (a, b) => (typeof __require !== "undefined" ? __require : a)[b]
27
- }) : x)(function(x) {
28
- if (typeof __require !== "undefined")
29
- return __require.apply(this, arguments);
30
- throw Error('Dynamic require of "' + x + '" is not supported');
31
- });
32
24
  function rootDir() {
33
25
  return process.cwd();
34
26
  }
35
27
  __name(rootDir, "rootDir");
36
- __name2(rootDir, "rootDir");
37
28
  function outputDirOverride() {
38
29
  const { CHROMATIC_ARCHIVE_LOCATION } = process.env;
39
30
  return CHROMATIC_ARCHIVE_LOCATION;
40
31
  }
41
32
  __name(outputDirOverride, "outputDirOverride");
42
- __name2(outputDirOverride, "outputDirOverride");
43
33
  function archivesDir(defaultOutputDir) {
44
34
  const outputDir = outputDirOverride() || defaultOutputDir;
45
35
  return path__default.default.resolve(rootDir(), outputDir, "chromatic-archives");
46
36
  }
47
37
  __name(archivesDir, "archivesDir");
48
- __name2(archivesDir, "archivesDir");
49
38
  function checkArchivesDirExists(defaultOutputDir) {
50
39
  const dir = archivesDir(defaultOutputDir);
51
40
  if (!fs.existsSync(dir)) {
@@ -55,8 +44,9 @@ Please make sure that you have run your E2E tests, or have set the CHROMATIC_ARC
55
44
  }
56
45
  }
57
46
  __name(checkArchivesDirExists, "checkArchivesDirExists");
58
- __name2(checkArchivesDirExists, "checkArchivesDirExists");
59
- var req = __require2.resolve ? __require2 : module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('out.js', document.baseURI).href)));
47
+
48
+ // ../shared/src/archive-storybook/index.ts
49
+ var req = __require.resolve ? __require : module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('out.js', document.baseURI).href)));
60
50
  function archiveStorybook(processArgs, configDir2, defaultOutputDir) {
61
51
  checkArchivesDirExists(defaultOutputDir);
62
52
  child_process.execFileSync("node", [
@@ -70,28 +60,12 @@ function archiveStorybook(processArgs, configDir2, defaultOutputDir) {
70
60
  });
71
61
  }
72
62
  __name(archiveStorybook, "archiveStorybook");
73
- __name2(archiveStorybook, "archiveStorybook");
74
- function buildArchiveStorybook(processArgs, configDir2, defaultOutputDir) {
75
- checkArchivesDirExists(defaultOutputDir);
76
- child_process.execFileSync("node", [
77
- binPath(),
78
- "build",
79
- ...processArgs,
80
- "-c",
81
- configDir2
82
- ], {
83
- stdio: "inherit"
84
- });
85
- }
86
- __name(buildArchiveStorybook, "buildArchiveStorybook");
87
- __name2(buildArchiveStorybook, "buildArchiveStorybook");
88
63
  function binPath() {
89
64
  const filename = req.resolve("storybook/package.json");
90
65
  const packageJson = JSON.parse(fs.readFileSync(filename, "utf8"));
91
66
  return path.resolve(path.dirname(filename), packageJson.bin);
92
67
  }
93
68
  __name(binPath, "binPath");
94
- __name2(binPath, "binPath");
95
69
 
96
70
  // src/constants.ts
97
71
  var DEFAULT_OUTPUT_DIR = "test-results";
@@ -5,6 +5,7 @@ var child_process = require('child_process');
5
5
  var path = require('path');
6
6
  var fs = require('fs');
7
7
  var module$1 = require('module');
8
+ require('crypto');
8
9
 
9
10
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
10
11
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
@@ -20,32 +21,20 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
20
21
  return require.apply(this, arguments);
21
22
  throw Error('Dynamic require of "' + x + '" is not supported');
22
23
  });
23
- var __defProp2 = Object.defineProperty;
24
- var __name2 = /* @__PURE__ */ __name((target, value) => __defProp2(target, "name", { value, configurable: true }), "__name");
25
- var __require2 = /* @__PURE__ */ ((x) => typeof __require !== "undefined" ? __require : typeof Proxy !== "undefined" ? new Proxy(x, {
26
- get: (a, b) => (typeof __require !== "undefined" ? __require : a)[b]
27
- }) : x)(function(x) {
28
- if (typeof __require !== "undefined")
29
- return __require.apply(this, arguments);
30
- throw Error('Dynamic require of "' + x + '" is not supported');
31
- });
32
24
  function rootDir() {
33
25
  return process.cwd();
34
26
  }
35
27
  __name(rootDir, "rootDir");
36
- __name2(rootDir, "rootDir");
37
28
  function outputDirOverride() {
38
29
  const { CHROMATIC_ARCHIVE_LOCATION } = process.env;
39
30
  return CHROMATIC_ARCHIVE_LOCATION;
40
31
  }
41
32
  __name(outputDirOverride, "outputDirOverride");
42
- __name2(outputDirOverride, "outputDirOverride");
43
33
  function archivesDir(defaultOutputDir) {
44
34
  const outputDir = outputDirOverride() || defaultOutputDir;
45
35
  return path__default.default.resolve(rootDir(), outputDir, "chromatic-archives");
46
36
  }
47
37
  __name(archivesDir, "archivesDir");
48
- __name2(archivesDir, "archivesDir");
49
38
  function checkArchivesDirExists(defaultOutputDir) {
50
39
  const dir = archivesDir(defaultOutputDir);
51
40
  if (!fs.existsSync(dir)) {
@@ -55,22 +44,9 @@ Please make sure that you have run your E2E tests, or have set the CHROMATIC_ARC
55
44
  }
56
45
  }
57
46
  __name(checkArchivesDirExists, "checkArchivesDirExists");
58
- __name2(checkArchivesDirExists, "checkArchivesDirExists");
59
- var req = __require2.resolve ? __require2 : module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('out.js', document.baseURI).href)));
60
- function archiveStorybook(processArgs, configDir2, defaultOutputDir) {
61
- checkArchivesDirExists(defaultOutputDir);
62
- child_process.execFileSync("node", [
63
- binPath(),
64
- "dev",
65
- ...processArgs,
66
- "-c",
67
- configDir2
68
- ], {
69
- stdio: "inherit"
70
- });
71
- }
72
- __name(archiveStorybook, "archiveStorybook");
73
- __name2(archiveStorybook, "archiveStorybook");
47
+
48
+ // ../shared/src/archive-storybook/index.ts
49
+ var req = __require.resolve ? __require : module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('out.js', document.baseURI).href)));
74
50
  function buildArchiveStorybook(processArgs, configDir2, defaultOutputDir) {
75
51
  checkArchivesDirExists(defaultOutputDir);
76
52
  child_process.execFileSync("node", [
@@ -84,14 +60,12 @@ function buildArchiveStorybook(processArgs, configDir2, defaultOutputDir) {
84
60
  });
85
61
  }
86
62
  __name(buildArchiveStorybook, "buildArchiveStorybook");
87
- __name2(buildArchiveStorybook, "buildArchiveStorybook");
88
63
  function binPath() {
89
64
  const filename = req.resolve("storybook/package.json");
90
65
  const packageJson = JSON.parse(fs.readFileSync(filename, "utf8"));
91
66
  return path.resolve(path.dirname(filename), packageJson.bin);
92
67
  }
93
68
  __name(binPath, "binPath");
94
- __name2(binPath, "binPath");
95
69
 
96
70
  // src/constants.ts
97
71
  var DEFAULT_OUTPUT_DIR = "test-results";
package/dist/index.d.mts CHANGED
@@ -1,14 +1,44 @@
1
- import { a } from './types-DBnTR0hb.js';
2
- export { a as ChromaticConfig } from './types-DBnTR0hb.js';
3
1
  import * as playwright_test from 'playwright/test';
4
2
  import { Page, TestInfo } from '@playwright/test';
5
3
  export { expect } from '@playwright/test';
6
4
 
5
+ interface ChromaticConfig {
6
+ /** https://www.chromatic.com/docs/delay/ */
7
+ delay?: number;
8
+ /** https://www.chromatic.com/docs/threshold/#anti-aliasing */
9
+ diffIncludeAntiAliasing?: boolean;
10
+ /** https://www.chromatic.com/docs/threshold/#setting-the-threshold */
11
+ diffThreshold?: number;
12
+ /** Disable the capture that happens automatically at the end of a test when using the Chromatic test fixture */
13
+ disableAutoSnapshot?: boolean;
14
+ /** https://www.chromatic.com/docs/media-features/#test-high-contrast-color-schemes */
15
+ forcedColors?: string;
16
+ /** https://www.chromatic.com/docs/animations/#css-animations */
17
+ pauseAnimationAtEnd?: boolean;
18
+ /** https://www.chromatic.com/docs/media-features/#verify-reduced-motion-animations */
19
+ prefersReducedMotion?: string;
20
+ /**
21
+ * Specify a network timeout, in milliseconds. This is the maximum amount of time that
22
+ * each test will wait for the network to be idle while archiving resources.
23
+ */
24
+ resourceArchiveTimeout?: number;
25
+ /**
26
+ * Domains (besides where the test is being run from) that assets should be archived from
27
+ * (needed when, for example, CI environment can't access the archives later on)
28
+ * ex: www.some-domain.com
29
+ */
30
+ assetDomains?: string[];
31
+ /** Crop snapshots to the viewport size. */
32
+ cropToViewport?: boolean;
33
+ /** CSS selectors of elements to ignore when comparing snapshots. */
34
+ ignoreSelectors?: string[];
35
+ }
36
+
7
37
  declare function takeSnapshot(page: Page, testInfo: TestInfo): Promise<void>;
8
38
  declare function takeSnapshot(page: Page, name: string, testInfo: TestInfo): Promise<void>;
9
39
 
10
- declare const test: playwright_test.TestType<playwright_test.PlaywrightTestArgs & playwright_test.PlaywrightTestOptions & a & {
40
+ declare const test: playwright_test.TestType<playwright_test.PlaywrightTestArgs & playwright_test.PlaywrightTestOptions & ChromaticConfig & {
11
41
  chromaticSnapshot: void;
12
42
  }, playwright_test.PlaywrightWorkerArgs & playwright_test.PlaywrightWorkerOptions>;
13
43
 
14
- export { takeSnapshot, test };
44
+ export { type ChromaticConfig, takeSnapshot, test };
package/dist/index.d.ts CHANGED
@@ -1,14 +1,44 @@
1
- import { a } from './types-DBnTR0hb.js';
2
- export { a as ChromaticConfig } from './types-DBnTR0hb.js';
3
1
  import * as playwright_test from 'playwright/test';
4
2
  import { Page, TestInfo } from '@playwright/test';
5
3
  export { expect } from '@playwright/test';
6
4
 
5
+ interface ChromaticConfig {
6
+ /** https://www.chromatic.com/docs/delay/ */
7
+ delay?: number;
8
+ /** https://www.chromatic.com/docs/threshold/#anti-aliasing */
9
+ diffIncludeAntiAliasing?: boolean;
10
+ /** https://www.chromatic.com/docs/threshold/#setting-the-threshold */
11
+ diffThreshold?: number;
12
+ /** Disable the capture that happens automatically at the end of a test when using the Chromatic test fixture */
13
+ disableAutoSnapshot?: boolean;
14
+ /** https://www.chromatic.com/docs/media-features/#test-high-contrast-color-schemes */
15
+ forcedColors?: string;
16
+ /** https://www.chromatic.com/docs/animations/#css-animations */
17
+ pauseAnimationAtEnd?: boolean;
18
+ /** https://www.chromatic.com/docs/media-features/#verify-reduced-motion-animations */
19
+ prefersReducedMotion?: string;
20
+ /**
21
+ * Specify a network timeout, in milliseconds. This is the maximum amount of time that
22
+ * each test will wait for the network to be idle while archiving resources.
23
+ */
24
+ resourceArchiveTimeout?: number;
25
+ /**
26
+ * Domains (besides where the test is being run from) that assets should be archived from
27
+ * (needed when, for example, CI environment can't access the archives later on)
28
+ * ex: www.some-domain.com
29
+ */
30
+ assetDomains?: string[];
31
+ /** Crop snapshots to the viewport size. */
32
+ cropToViewport?: boolean;
33
+ /** CSS selectors of elements to ignore when comparing snapshots. */
34
+ ignoreSelectors?: string[];
35
+ }
36
+
7
37
  declare function takeSnapshot(page: Page, testInfo: TestInfo): Promise<void>;
8
38
  declare function takeSnapshot(page: Page, name: string, testInfo: TestInfo): Promise<void>;
9
39
 
10
- declare const test: playwright_test.TestType<playwright_test.PlaywrightTestArgs & playwright_test.PlaywrightTestOptions & a & {
40
+ declare const test: playwright_test.TestType<playwright_test.PlaywrightTestArgs & playwright_test.PlaywrightTestOptions & ChromaticConfig & {
11
41
  chromaticSnapshot: void;
12
42
  }, playwright_test.PlaywrightWorkerArgs & playwright_test.PlaywrightWorkerOptions>;
13
43
 
14
- export { takeSnapshot, test };
44
+ export { type ChromaticConfig, takeSnapshot, test };