@argos-ci/playwright 6.5.0 → 6.6.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,22 +1,22 @@
1
1
  async function argosAriaSnapshot(...args) {
2
- const { argosAriaSnapshot } = await import("./index.js");
2
+ const { argosAriaSnapshot } = await import("./index.mjs");
3
3
  return argosAriaSnapshot(...args);
4
4
  }
5
5
 
6
6
  async function argosScreenshot(...args) {
7
- const { argosScreenshot } = await import("./index.js");
7
+ const { argosScreenshot } = await import("./index.mjs");
8
8
  return argosScreenshot(...args);
9
9
  }
10
10
 
11
11
  function getCSPScriptHash(...args) {
12
12
  // Loading ESM using require works in Node.js v22.13.0+
13
- const { getCSPScriptHash } = require("./index.js");
13
+ const { getCSPScriptHash } = require("./index.mjs");
14
14
  return getCSPScriptHash(...args);
15
15
  }
16
16
 
17
17
  function DO_NOT_USE_setMetadataConfig(...args) {
18
18
  // Loading ESM using require works in Node.js v22.13.0+
19
- const { DO_NOT_USE_setMetadataConfig } = require("./index.js");
19
+ const { DO_NOT_USE_setMetadataConfig } = require("./index.mjs");
20
20
  return DO_NOT_USE_setMetadataConfig(...args);
21
21
  }
22
22
 
@@ -0,0 +1,185 @@
1
+ import { ScreenshotMetadata } from "@argos-ci/util";
2
+ import { StabilizationPluginOptions, ViewportOption } from "@argos-ci/browser";
3
+ import { ElementHandle, Frame, Locator, LocatorScreenshotOptions, Page, PageScreenshotOptions } from "@playwright/test";
4
+ //#region ../../node_modules/.pnpm/playwright@1.58.2/node_modules/playwright/types/test.d.ts
5
+ // --- BEGINGLOBAL ---
6
+ declare global {
7
+ export namespace PlaywrightTest {
8
+ export interface Matchers<R, T = unknown> {}
9
+ }
10
+ } // --- ENDGLOBAL ---
11
+ /**
12
+ * These tests are executed in Playwright environment that launches the browser
13
+ * and provides a fresh page to each test.
14
+ */
15
+ //#endregion
16
+ //#region src/attachment.d.ts
17
+ type ArgosAttachment = {
18
+ name: string;
19
+ contentType: string;
20
+ path: string;
21
+ };
22
+ //#endregion
23
+ //#region src/aria-snapshot.d.ts
24
+ type LocatorOptions$1 = Parameters<Page["locator"]>[1];
25
+ type ArgosSnapshotOptions = {
26
+ /**
27
+ * `Locator` or string selector of the element to take a snapshot of.
28
+ */
29
+ element?: string | Locator;
30
+ /**
31
+ * Folder where the snapshots will be saved if not using the Argos reporter.
32
+ * @default "./screenshots"
33
+ */
34
+ root?: string;
35
+ /**
36
+ * Wait for the UI to stabilize before taking the snapshot.
37
+ * Set to `false` to disable stabilization.
38
+ * Pass an object to customize the stabilization.
39
+ * @default true
40
+ */
41
+ stabilize?: boolean | StabilizationPluginOptions;
42
+ /**
43
+ * Maximum time in milliseconds. Defaults to `0` - no timeout
44
+ */
45
+ timeout?: number;
46
+ } & LocatorOptions$1;
47
+ /**
48
+ * Stabilize the UI and takes a snapshot of the application under test.
49
+ *
50
+ * @example
51
+ * argosAriaSnapshot(page, "my-screenshot")
52
+ * @see https://playwright.dev/docs/aria-snapshots
53
+ */
54
+ declare function argosAriaSnapshot(
55
+ /**
56
+ * Playwright `page` or `frame` object.
57
+ */
58
+
59
+ handler: Page | Frame,
60
+ /**
61
+ * Name of the snapshot. Must be unique.
62
+ */
63
+
64
+ name: string,
65
+ /**
66
+ * Options for the snapshot.
67
+ */
68
+
69
+ options?: ArgosSnapshotOptions): Promise<ArgosAttachment[]>;
70
+ //#endregion
71
+ //#region src/screenshot.d.ts
72
+ type LocatorOptions = Parameters<Page["locator"]>[1];
73
+ type ScreenshotOptions<TBase extends PageScreenshotOptions | LocatorScreenshotOptions> = Omit<TBase, "encoding" | "type" | "omitBackground" | "path">;
74
+ type ArgosScreenshotOptions = {
75
+ /**
76
+ * `Locator` or string selector of the element to take a screenshot of.
77
+ * Passing an `ElementHandle` is discouraged, use a `Locator` instead.
78
+ */
79
+ element?: string | ElementHandle | Locator;
80
+ /**
81
+ * Viewports to take screenshots of.
82
+ */
83
+ viewports?: ViewportOption[];
84
+ /**
85
+ * Capture an ARIA snapshot along with the screenshot.
86
+ * Each ARIA snapshot counts as an additional screenshot for billing.
87
+ * When using the viewports setting, one ARIA snapshot is taken per viewport.
88
+ * @see https://playwright.dev/docs/aria-snapshots#aria-snapshots
89
+ * @default false
90
+ */
91
+ ariaSnapshot?: boolean;
92
+ /**
93
+ * Custom CSS evaluated during the screenshot process.
94
+ */
95
+ argosCSS?: string;
96
+ /**
97
+ * Disable hover effects by moving the mouse to the top-left corner of the document.
98
+ * @default true
99
+ */
100
+ disableHover?: boolean;
101
+ /**
102
+ * Sensitivity threshold between 0 and 1.
103
+ * The higher the threshold, the less sensitive the diff will be.
104
+ * @default 0.5
105
+ */
106
+ threshold?: number;
107
+ /**
108
+ * Folder where the screenshots will be saved if not using the Argos reporter.
109
+ * @default "./screenshots"
110
+ */
111
+ root?: string;
112
+ /**
113
+ * Tag or array of tags to attach to the screenshot.
114
+ */
115
+ tag?: string | string[];
116
+ /**
117
+ * Wait for the UI to stabilize before taking the screenshot.
118
+ * Set to `false` to disable stabilization.
119
+ * Pass an object to customize the stabilization.
120
+ * @default true
121
+ */
122
+ stabilize?: boolean | StabilizationPluginOptions;
123
+ /**
124
+ * Run a function before taking the screenshot.
125
+ * When using viewports, this function will run before taking sreenshots on each viewport.
126
+ */
127
+ beforeScreenshot?: (api: {
128
+ /**
129
+ * Run Argos stabilization alorithm.
130
+ * Accepts an object to customize the stabilization.
131
+ * Note that this function is independent of the `stabilize` option.
132
+ */
133
+ runStabilization: (options?: StabilizationPluginOptions) => Promise<void>;
134
+ }) => Promise<void> | void;
135
+ /**
136
+ * Run a function after taking the screenshot.
137
+ * When using viewports, this function will run after taking sreenshots on each viewport.
138
+ */
139
+ afterScreenshot?: () => Promise<void> | void;
140
+ } & LocatorOptions & ScreenshotOptions<LocatorScreenshotOptions> & ScreenshotOptions<PageScreenshotOptions>;
141
+ /**
142
+ * Stabilize the UI and takes a screenshot of the application under test.
143
+ *
144
+ * @example
145
+ * argosScreenshot(page, "my-screenshot")
146
+ * @see https://argos-ci.com/docs/playwright#api-overview
147
+ */
148
+ declare function argosScreenshot(
149
+ /**
150
+ * Playwright `page` or `frame` object.
151
+ */
152
+
153
+ handler: Page | Frame,
154
+ /**
155
+ * Name of the screenshot. Must be unique.
156
+ */
157
+
158
+ name: string,
159
+ /**
160
+ * Options for the screenshot.
161
+ */
162
+
163
+ options?: ArgosScreenshotOptions): Promise<ArgosAttachment[]>;
164
+ //#endregion
165
+ //#region src/csp.d.ts
166
+ /**
167
+ * Get the CSP script hash.
168
+ */
169
+ declare function getCSPScriptHash(): string;
170
+ //#endregion
171
+ //#region src/metadata.d.ts
172
+ type MetadataConfig = {
173
+ sdk: ScreenshotMetadata["sdk"];
174
+ playwrightLibraries: string[];
175
+ url?: string;
176
+ test?: ScreenshotMetadata["test"];
177
+ story?: ScreenshotMetadata["story"];
178
+ viewport?: ScreenshotMetadata["viewport"];
179
+ };
180
+ /**
181
+ * Set the metadata config.
182
+ */
183
+ declare function setMetadataConfig(metadata: MetadataConfig): void;
184
+ //#endregion
185
+ export { type ArgosAttachment, type ArgosScreenshotOptions, type ArgosSnapshotOptions, setMetadataConfig as DO_NOT_USE_setMetadataConfig, type MetadataConfig, argosAriaSnapshot, argosScreenshot, getCSPScriptHash };