@argos-ci/playwright 3.10.0 → 4.1.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/dist/index.d.ts +8 -1
- package/dist/index.js +27 -22
- package/dist/reporter.d.ts +3 -3
- package/dist/reporter.js +7 -3
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -45,7 +45,14 @@ type ArgosScreenshotOptions = {
|
|
|
45
45
|
* Run a function before taking the screenshot.
|
|
46
46
|
* When using viewports, this function will run before taking sreenshots on each viewport.
|
|
47
47
|
*/
|
|
48
|
-
beforeScreenshot?: (
|
|
48
|
+
beforeScreenshot?: (api: {
|
|
49
|
+
/**
|
|
50
|
+
* Run Argos stabilization alorithm.
|
|
51
|
+
* Accepts an object to customize the stabilization.
|
|
52
|
+
* Note that this function is independent of the `stabilize` option.
|
|
53
|
+
*/
|
|
54
|
+
runStabilization: (options?: StabilizationOptions) => Promise<void>;
|
|
55
|
+
}) => Promise<void> | void;
|
|
49
56
|
/**
|
|
50
57
|
* Run a function after taking the screenshot.
|
|
51
58
|
* When using viewports, this function will run after taking sreenshots on each viewport.
|
package/dist/index.js
CHANGED
|
@@ -123,7 +123,7 @@ async function getTestInfo() {
|
|
|
123
123
|
try {
|
|
124
124
|
const { test } = await import("@playwright/test");
|
|
125
125
|
return test.info();
|
|
126
|
-
} catch
|
|
126
|
+
} catch {
|
|
127
127
|
return null;
|
|
128
128
|
}
|
|
129
129
|
}
|
|
@@ -179,7 +179,7 @@ async function argosScreenshot(page, name, options = {}) {
|
|
|
179
179
|
has,
|
|
180
180
|
hasText,
|
|
181
181
|
viewports,
|
|
182
|
-
argosCSS,
|
|
182
|
+
argosCSS: _argosCSS,
|
|
183
183
|
stabilize = true,
|
|
184
184
|
root = DEFAULT_SCREENSHOT_ROOT,
|
|
185
185
|
...playwrightOptions
|
|
@@ -222,8 +222,9 @@ async function argosScreenshot(page, name, options = {}) {
|
|
|
222
222
|
}
|
|
223
223
|
const browserName = browser.browserType().name();
|
|
224
224
|
const browserVersion = browser.version();
|
|
225
|
+
const url = page.url();
|
|
225
226
|
const metadata = {
|
|
226
|
-
url
|
|
227
|
+
url,
|
|
227
228
|
viewport: viewportSize,
|
|
228
229
|
colorScheme,
|
|
229
230
|
mediaType,
|
|
@@ -236,28 +237,32 @@ async function argosScreenshot(page, name, options = {}) {
|
|
|
236
237
|
};
|
|
237
238
|
return metadata;
|
|
238
239
|
};
|
|
239
|
-
const
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
)
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
`
|
|
240
|
+
const runStabilization = async (options2 = {}) => {
|
|
241
|
+
try {
|
|
242
|
+
await page.waitForFunction(
|
|
243
|
+
(options3) => window.__ARGOS__.checkIsStable(options3),
|
|
244
|
+
options2
|
|
245
|
+
);
|
|
246
|
+
} catch (error) {
|
|
247
|
+
const reasons = await page.evaluate(
|
|
248
|
+
(options3) => window.__ARGOS__.getStabilityFailureReasons(
|
|
249
|
+
options3
|
|
250
|
+
),
|
|
251
|
+
options2
|
|
252
|
+
);
|
|
253
|
+
throw new Error(
|
|
254
|
+
`
|
|
255
255
|
Failed to stabilize screenshot, found the following issues:
|
|
256
256
|
${reasons.map((reason) => `- ${reason}`).join("\n")}
|
|
257
257
|
`.trim(),
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
258
|
+
{ cause: error }
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
const stabilizeAndScreenshot = async (name2) => {
|
|
263
|
+
await options.beforeScreenshot?.({ runStabilization });
|
|
264
|
+
if (stabilize) {
|
|
265
|
+
await runStabilization(stabilize === true ? void 0 : stabilize);
|
|
261
266
|
}
|
|
262
267
|
const names = getScreenshotNames(name2, testInfo);
|
|
263
268
|
const metadata = await collectMetadata(testInfo);
|
package/dist/reporter.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Reporter, FullConfig, TestResult,
|
|
1
|
+
import { Reporter, FullConfig, TestResult, TestCase, FullResult } from '@playwright/test/reporter';
|
|
2
2
|
import { UploadParameters } from '@argos-ci/core';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -18,7 +18,7 @@ type DynamicBuildName<T extends readonly string[]> = {
|
|
|
18
18
|
*/
|
|
19
19
|
get: (test: TestCase) => T[number];
|
|
20
20
|
};
|
|
21
|
-
type ArgosReporterOptions<T extends string[] = string[]> = Omit<UploadParameters, "files" | "root" | "buildName"> & {
|
|
21
|
+
type ArgosReporterOptions<T extends string[] = string[]> = Omit<UploadParameters, "files" | "root" | "buildName" | "metadata"> & {
|
|
22
22
|
/**
|
|
23
23
|
* Upload the report to Argos.
|
|
24
24
|
* @default true
|
|
@@ -54,7 +54,7 @@ declare class ArgosReporter implements Reporter {
|
|
|
54
54
|
* Get the root upload directory (cached).
|
|
55
55
|
*/
|
|
56
56
|
getRootUploadDirectory(): Promise<string>;
|
|
57
|
-
onBegin(config: FullConfig
|
|
57
|
+
onBegin(config: FullConfig): void;
|
|
58
58
|
onTestEnd(test: TestCase, result: TestResult): Promise<void>;
|
|
59
59
|
onEnd(result: FullResult): Promise<{
|
|
60
60
|
status: "failed";
|
package/dist/reporter.js
CHANGED
|
@@ -153,8 +153,12 @@ function createArgosReporterOptions(options) {
|
|
|
153
153
|
return options;
|
|
154
154
|
}
|
|
155
155
|
async function getParallelFromConfig(config) {
|
|
156
|
-
if (!config.shard)
|
|
157
|
-
|
|
156
|
+
if (!config.shard) {
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
if (config.shard.total === 1) {
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
158
162
|
const argosConfig = await readConfig();
|
|
159
163
|
if (!argosConfig.parallelNonce) {
|
|
160
164
|
throw new Error(
|
|
@@ -221,7 +225,7 @@ var ArgosReporter = class {
|
|
|
221
225
|
}
|
|
222
226
|
return this.rootUploadDirectoryPromise;
|
|
223
227
|
}
|
|
224
|
-
onBegin(config
|
|
228
|
+
onBegin(config) {
|
|
225
229
|
debug("ArgosReporter:onBegin");
|
|
226
230
|
this.playwrightConfig = config;
|
|
227
231
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@argos-ci/playwright",
|
|
3
3
|
"description": "Playwright SDK for visual testing with Argos.",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "4.1.0",
|
|
5
5
|
"author": "Smooth Code",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -47,14 +47,14 @@
|
|
|
47
47
|
"node": ">=18.16.0"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@argos-ci/browser": "
|
|
51
|
-
"@argos-ci/core": "3.
|
|
52
|
-
"@argos-ci/util": "2.
|
|
50
|
+
"@argos-ci/browser": "3.0.1",
|
|
51
|
+
"@argos-ci/core": "3.1.0",
|
|
52
|
+
"@argos-ci/util": "2.3.0",
|
|
53
53
|
"chalk": "^5.4.1",
|
|
54
54
|
"debug": "^4.4.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@argos-ci/cli": "
|
|
57
|
+
"@argos-ci/cli": "2.5.5",
|
|
58
58
|
"@argos-ci/playwright": "workspace:.",
|
|
59
59
|
"@playwright/test": "^1.49.1",
|
|
60
60
|
"@types/debug": "^4.1.12",
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"test": "pnpm exec -- playwright test",
|
|
66
66
|
"e2e": "UPLOAD_TO_ARGOS=true pnpm run test"
|
|
67
67
|
},
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "8d46b4d4fc2b59b4fe93bac6fda02fb18440f935"
|
|
69
69
|
}
|