@argos-ci/playwright 5.0.1 → 5.0.3

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.
Files changed (2) hide show
  1. package/dist/index.js +30 -10
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -177,13 +177,33 @@ async function beforeEach(page, options) {
177
177
  );
178
178
  };
179
179
  }
180
+ async function increaseTimeout() {
181
+ const testInfo = await getTestInfo();
182
+ if (testInfo) {
183
+ const { timeout } = testInfo;
184
+ testInfo.setTimeout(timeout * 3);
185
+ return {
186
+ value: timeout,
187
+ reset: () => {
188
+ testInfo.setTimeout(timeout);
189
+ }
190
+ };
191
+ }
192
+ return null;
193
+ }
180
194
  async function waitForReadiness(page, options) {
181
195
  const context = getStabilizationContext(options);
196
+ const timeout = await increaseTimeout();
182
197
  try {
183
198
  await page.waitForFunction(
184
- (context2) => window.__ARGOS__.waitFor(context2),
185
- context
199
+ (context2) => {
200
+ const argos = window.__ARGOS__;
201
+ return argos.waitFor(context2);
202
+ },
203
+ context,
204
+ timeout ? { timeout: timeout.value } : void 0
186
205
  );
206
+ timeout?.reset();
187
207
  } catch (error) {
188
208
  const reasons = await page.evaluate(
189
209
  (context2) => window.__ARGOS__.getWaitFailureExplanations(
@@ -277,14 +297,6 @@ async function argosScreenshot(page, name, options = {}) {
277
297
  return metadata;
278
298
  };
279
299
  const stabilizeAndScreenshot = async (name2) => {
280
- await options.beforeScreenshot?.({
281
- runStabilization: (stabilizationOptions) => waitForReadiness(page, {
282
- ...options,
283
- stabilize: stabilizationOptions ?? options.stabilize
284
- })
285
- });
286
- await waitForReadiness(page, options);
287
- const afterEach = await beforeEach(page, options);
288
300
  const names = getScreenshotNames(name2, testInfo);
289
301
  const metadata = await collectMetadata(testInfo);
290
302
  metadata.transient = {};
@@ -300,6 +312,14 @@ async function argosScreenshot(page, name, options = {}) {
300
312
  if (dir !== root) {
301
313
  await mkdir(dirname(screenshotPath), { recursive: true });
302
314
  }
315
+ await options.beforeScreenshot?.({
316
+ runStabilization: (stabilizationOptions) => waitForReadiness(page, {
317
+ ...options,
318
+ stabilize: stabilizationOptions ?? options.stabilize
319
+ })
320
+ });
321
+ await waitForReadiness(page, options);
322
+ const afterEach = await beforeEach(page, options);
303
323
  await Promise.all([
304
324
  handle.screenshot({
305
325
  path: screenshotPath,
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": "5.0.1",
4
+ "version": "5.0.3",
5
5
  "author": "Smooth Code",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -47,7 +47,7 @@
47
47
  "node": ">=18.16.0"
48
48
  },
49
49
  "dependencies": {
50
- "@argos-ci/browser": "4.0.1",
50
+ "@argos-ci/browser": "4.1.1",
51
51
  "@argos-ci/core": "3.1.1",
52
52
  "@argos-ci/util": "2.3.1",
53
53
  "chalk": "^5.4.1",
@@ -67,5 +67,5 @@
67
67
  "check-format": "prettier --check --ignore-unknown --ignore-path=../../.gitignore --ignore-path=../../.prettierignore .",
68
68
  "lint": "eslint ."
69
69
  },
70
- "gitHead": "333ae8a299204b5d32edcdec5b7cb9bbb54766ca"
70
+ "gitHead": "fe8946c2796b7565834b4ec275e50f6bad20f498"
71
71
  }