@argos-ci/puppeteer 3.1.3 → 3.2.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.
Files changed (2) hide show
  1. package/dist/index.js +28 -14
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -61,11 +61,14 @@ async function setViewportSize(page, viewportSize) {
61
61
  { width: viewportSize.width, height: viewportSize.height }
62
62
  );
63
63
  }
64
- async function setup(page, options) {
64
+ async function beforeAll(page, options) {
65
65
  const { disableHover = true, argosCSS } = options;
66
66
  const fullPage = checkIsFullPage(options);
67
67
  await page.evaluate(
68
- ({ fullPage: fullPage2, argosCSS: argosCSS2 }) => window.__ARGOS__.setup({ fullPage: fullPage2, argosCSS: argosCSS2 }),
68
+ ({ fullPage: fullPage2, argosCSS: argosCSS2 }) => window.__ARGOS__.beforeAll({
69
+ fullPage: fullPage2,
70
+ argosCSS: argosCSS2
71
+ }),
69
72
  { fullPage, argosCSS }
70
73
  );
71
74
  if (disableHover) {
@@ -73,11 +76,23 @@ async function setup(page, options) {
73
76
  }
74
77
  return async () => {
75
78
  await page.evaluate(
76
- ({ fullPage: fullPage2, argosCSS: argosCSS2 }) => window.__ARGOS__.teardown({
77
- fullPage: fullPage2,
78
- argosCSS: argosCSS2
79
- }),
80
- { fullPage, argosCSS }
79
+ () => window.__ARGOS__.afterAll()
80
+ );
81
+ };
82
+ }
83
+ async function beforeEach(page, options) {
84
+ const { argosCSS } = options;
85
+ const fullPage = checkIsFullPage(options);
86
+ await page.evaluate(
87
+ ({ fullPage: fullPage2, argosCSS: argosCSS2 }) => window.__ARGOS__.beforeEach({
88
+ fullPage: fullPage2,
89
+ argosCSS: argosCSS2
90
+ }),
91
+ { fullPage, argosCSS }
92
+ );
93
+ return async () => {
94
+ await page.evaluate(
95
+ () => window.__ARGOS__.afterEach()
81
96
  );
82
97
  };
83
98
  }
@@ -100,7 +115,7 @@ async function argosScreenshot(page, name, options = {}) {
100
115
  // Inject Argos script into the page
101
116
  injectArgos(page)
102
117
  ]);
103
- const teardown = await setup(page, options);
118
+ const afterAll = await beforeAll(page, options);
104
119
  const fullPage = checkIsFullPage(options);
105
120
  async function collectMetadata() {
106
121
  const [
@@ -152,13 +167,13 @@ async function argosScreenshot(page, name, options = {}) {
152
167
  const stabilizationOptions = typeof stabilize === "object" ? stabilize : {};
153
168
  try {
154
169
  await page.waitForFunction(
155
- (options2) => window.__ARGOS__.checkIsStable(options2),
170
+ (options2) => window.__ARGOS__.waitFor(options2),
156
171
  void 0,
157
172
  stabilizationOptions
158
173
  );
159
174
  } catch (error) {
160
175
  const reasons = await page.evaluate(
161
- (options2) => window.__ARGOS__.getStabilityFailureReasons(options2),
176
+ (options2) => window.__ARGOS__.getWaitFailureExplanations(options2),
162
177
  stabilizationOptions
163
178
  );
164
179
  throw new Error(
@@ -170,6 +185,7 @@ ${reasons.map((reason) => `- ${reason}`).join("\n")}
170
185
  );
171
186
  }
172
187
  }
188
+ const afterEach = await beforeEach(page, options);
173
189
  const [screenshotPath, metadata] = await Promise.all([
174
190
  getScreenshotPath(name2),
175
191
  collectMetadata()
@@ -193,9 +209,7 @@ ${reasons.map((reason) => `- ${reason}`).join("\n")}
193
209
  } else {
194
210
  await element.screenshot(screenshotOptions);
195
211
  }
196
- await page.evaluate(
197
- () => window.__ARGOS__.afterEach()
198
- );
212
+ await afterEach();
199
213
  }
200
214
  if (viewports) {
201
215
  for (const viewport of viewports) {
@@ -209,7 +223,7 @@ ${reasons.map((reason) => `- ${reason}`).join("\n")}
209
223
  } else {
210
224
  await stabilizeAndScreenshot(name);
211
225
  }
212
- await teardown();
226
+ await afterAll();
213
227
  }
214
228
  export {
215
229
  argosScreenshot
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@argos-ci/puppeteer",
3
3
  "description": "Puppeteer SDK for visual testing with Argos.",
4
- "version": "3.1.3",
4
+ "version": "3.2.0",
5
5
  "author": "Smooth Code",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -42,7 +42,7 @@
42
42
  "puppeteer": ">=1"
43
43
  },
44
44
  "dependencies": {
45
- "@argos-ci/browser": "3.1.3",
45
+ "@argos-ci/browser": "3.2.0",
46
46
  "@argos-ci/util": "2.3.0"
47
47
  },
48
48
  "devDependencies": {
@@ -62,5 +62,5 @@
62
62
  "argos-upload": "pnpm exec argos upload screenshots --build-name \"argos-puppeteer-e2e-node-$NODE_VERSION-$OS\"",
63
63
  "e2e": "pnpm run test && pnpm run argos-upload"
64
64
  },
65
- "gitHead": "4f538068d5e42c378acdbaca292ab8cb1b49d031"
65
+ "gitHead": "fae9639b570fb2cd937ce8695eed1941c25678db"
66
66
  }