@applitools/eyes-storybook 3.53.4 → 3.53.6

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/CHANGELOG.md CHANGED
@@ -1,5 +1,77 @@
1
1
  # Changelog
2
2
 
3
+ ## [3.53.6](https://github.com/Applitools-Dev/sdk/compare/js/eyes-storybook@3.53.5...js/eyes-storybook@3.53.6) (2025-01-30)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * storybook exception and add logs ([#2760](https://github.com/Applitools-Dev/sdk/issues/2760)) ([357193a](https://github.com/Applitools-Dev/sdk/commit/357193ad0f18eae729b4064d14d781e2401c70f7))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * @applitools/dom-snapshot bumped to 4.11.15
14
+
15
+ * @applitools/driver bumped to 1.20.4
16
+ #### Bug Fixes
17
+
18
+ * handle device screen info extraction gracefully ([#2757](https://github.com/Applitools-Dev/sdk/issues/2757)) ([92d0118](https://github.com/Applitools-Dev/sdk/commit/92d0118137b77e49d780092d110973df8ed8b40c))
19
+ * @applitools/eyes bumped to 1.32.0
20
+ #### Features
21
+
22
+ * remove iPhoneX from list of available UFG Safari devices ([#2756](https://github.com/Applitools-Dev/sdk/issues/2756)) ([e24d054](https://github.com/Applitools-Dev/sdk/commit/e24d054328df900fbc4988fdbf8213aadffa9a37))
23
+
24
+
25
+
26
+ * @applitools/spec-driver-webdriver bumped to 1.1.25
27
+
28
+ * @applitools/spec-driver-selenium bumped to 1.5.95
29
+
30
+ * @applitools/spec-driver-puppeteer bumped to 1.4.24
31
+
32
+ * @applitools/screenshoter bumped to 3.10.5
33
+
34
+ * @applitools/nml-client bumped to 1.8.24
35
+
36
+ * @applitools/ufg-client bumped to 1.16.3
37
+ #### Bug Fixes
38
+
39
+ * unthrottle renders in offline mode ([#2754](https://github.com/Applitools-Dev/sdk/issues/2754)) ([b65d816](https://github.com/Applitools-Dev/sdk/commit/b65d81610504ae725b7b52611282a1bb28a049fe))
40
+ * @applitools/ec-client bumped to 1.10.3
41
+
42
+ * @applitools/core bumped to 4.31.0
43
+ #### Features
44
+
45
+ * remove iPhoneX from list of available UFG Safari devices ([#2756](https://github.com/Applitools-Dev/sdk/issues/2756)) ([e24d054](https://github.com/Applitools-Dev/sdk/commit/e24d054328df900fbc4988fdbf8213aadffa9a37))
46
+
47
+
48
+ #### Bug Fixes
49
+
50
+ * handle device screen info extraction gracefully ([#2757](https://github.com/Applitools-Dev/sdk/issues/2757)) ([92d0118](https://github.com/Applitools-Dev/sdk/commit/92d0118137b77e49d780092d110973df8ed8b40c))
51
+ * unthrottle renders in offline mode ([#2754](https://github.com/Applitools-Dev/sdk/issues/2754)) ([b65d816](https://github.com/Applitools-Dev/sdk/commit/b65d81610504ae725b7b52611282a1bb28a049fe))
52
+
53
+
54
+
55
+
56
+ ## [3.53.5](https://github.com/Applitools-Dev/sdk/compare/js/eyes-storybook@3.53.4...js/eyes-storybook@3.53.5) (2025-01-23)
57
+
58
+
59
+ ### Bug Fixes
60
+
61
+ * stabilize page in storybook ([#2751](https://github.com/Applitools-Dev/sdk/issues/2751)) ([2a3b85e](https://github.com/Applitools-Dev/sdk/commit/2a3b85e2b052cd44260c11622b91b8a5c94736a8))
62
+
63
+
64
+ ### Dependencies
65
+
66
+ * @applitools/ufg-client bumped to 1.16.2
67
+ #### Bug Fixes
68
+
69
+ * stabilize page in storybook ([#2751](https://github.com/Applitools-Dev/sdk/issues/2751)) ([2a3b85e](https://github.com/Applitools-Dev/sdk/commit/2a3b85e2b052cd44260c11622b91b8a5c94736a8))
70
+ * @applitools/core bumped to 4.30.1
71
+
72
+ * @applitools/eyes bumped to 1.31.3
73
+
74
+
3
75
  ## [3.53.4](https://github.com/Applitools-Dev/sdk/compare/js/eyes-storybook@3.53.3...js/eyes-storybook@3.53.4) (2025-01-22)
4
76
 
5
77
 
@@ -38,7 +38,16 @@ function __getClientAPI(...args) {
38
38
  ) {
39
39
  return API_VERSIONS.v4;
40
40
  } else {
41
- throw new Error("Cannot get client API: couldn't detect storybook version");
41
+ const storybookVariablesOnWindow = Object.keys(frameWindow).filter(key =>
42
+ key.includes('STORYBOOK'),
43
+ );
44
+ throw new Error(
45
+ `Cannot get client API: couldn't detect storybook version.${
46
+ storybookVariablesOnWindow.length
47
+ ? ` Found the following storybook variables: ${storybookVariablesOnWindow.join(', ')}`
48
+ : ' - no STORYBOOK variables found in global scope'
49
+ }`,
50
+ );
42
51
  }
43
52
  }
44
53
  function onStoryRendered(callback) {
@@ -181,13 +190,18 @@ function __getClientAPI(...args) {
181
190
  throw new Error('Cannot get client API: no frameWindow');
182
191
  }
183
192
 
184
- async function getClientAPIWithRetries() {
193
+ async function getClientAPIWithRetries({timeout = 10000} = {}) {
185
194
  let error = 'Unknown error';
186
- for (let attempt = 1; attempt <= 100; attempt++) {
187
- await new Promise(resolve => setTimeout(resolve, 100));
195
+ const RETRY_INTERVAL = 100;
196
+ const totalAttempts = timeout / RETRY_INTERVAL;
197
+ for (let attempt = 1; attempt <= totalAttempts; attempt++) {
198
+ await new Promise(resolve => setTimeout(resolve, RETRY_INTERVAL));
188
199
  try {
189
200
  return getClientAPI();
190
201
  } catch (e) {
202
+ if (!(attempt % 10)) {
203
+ console.log(`Error in getClientAPI: ${e.message}, attempt ${attempt}/${totalAttempts}`);
204
+ }
191
205
  error = e;
192
206
  }
193
207
  }
@@ -38,7 +38,16 @@ function __getStories(...args) {
38
38
  ) {
39
39
  return API_VERSIONS.v4;
40
40
  } else {
41
- throw new Error("Cannot get client API: couldn't detect storybook version");
41
+ const storybookVariablesOnWindow = Object.keys(frameWindow).filter(key =>
42
+ key.includes('STORYBOOK'),
43
+ );
44
+ throw new Error(
45
+ `Cannot get client API: couldn't detect storybook version.${
46
+ storybookVariablesOnWindow.length
47
+ ? ` Found the following storybook variables: ${storybookVariablesOnWindow.join(', ')}`
48
+ : ' - no STORYBOOK variables found in global scope'
49
+ }`,
50
+ );
42
51
  }
43
52
  }
44
53
  function onStoryRendered(callback) {
@@ -181,13 +190,18 @@ function __getStories(...args) {
181
190
  throw new Error('Cannot get client API: no frameWindow');
182
191
  }
183
192
 
184
- async function getClientAPIWithRetries() {
193
+ async function getClientAPIWithRetries({timeout = 10000} = {}) {
185
194
  let error = 'Unknown error';
186
- for (let attempt = 1; attempt <= 100; attempt++) {
187
- await new Promise(resolve => setTimeout(resolve, 100));
195
+ const RETRY_INTERVAL = 100;
196
+ const totalAttempts = timeout / RETRY_INTERVAL;
197
+ for (let attempt = 1; attempt <= totalAttempts; attempt++) {
198
+ await new Promise(resolve => setTimeout(resolve, RETRY_INTERVAL));
188
199
  try {
189
200
  return getClientAPI();
190
201
  } catch (e) {
202
+ if (!(attempt % 10)) {
203
+ console.log(`Error in getClientAPI: ${e.message}, attempt ${attempt}/${totalAttempts}`);
204
+ }
191
205
  error = e;
192
206
  }
193
207
  }
@@ -368,7 +382,7 @@ function __getStories(...args) {
368
382
 
369
383
  async function _waitForClientAPI() {
370
384
  try {
371
- return getClientAPI_1();
385
+ return getClientAPI_1({timeout});
372
386
  } catch (ex) {
373
387
  await delay(100);
374
388
  return _waitForClientAPI();
@@ -38,7 +38,16 @@ function __renderStoryWithClientAPI(...args) {
38
38
  ) {
39
39
  return API_VERSIONS.v4;
40
40
  } else {
41
- throw new Error("Cannot get client API: couldn't detect storybook version");
41
+ const storybookVariablesOnWindow = Object.keys(frameWindow).filter(key =>
42
+ key.includes('STORYBOOK'),
43
+ );
44
+ throw new Error(
45
+ `Cannot get client API: couldn't detect storybook version.${
46
+ storybookVariablesOnWindow.length
47
+ ? ` Found the following storybook variables: ${storybookVariablesOnWindow.join(', ')}`
48
+ : ' - no STORYBOOK variables found in global scope'
49
+ }`,
50
+ );
42
51
  }
43
52
  }
44
53
  function onStoryRendered(callback) {
@@ -181,13 +190,18 @@ function __renderStoryWithClientAPI(...args) {
181
190
  throw new Error('Cannot get client API: no frameWindow');
182
191
  }
183
192
 
184
- async function getClientAPIWithRetries() {
193
+ async function getClientAPIWithRetries({timeout = 10000} = {}) {
185
194
  let error = 'Unknown error';
186
- for (let attempt = 1; attempt <= 100; attempt++) {
187
- await new Promise(resolve => setTimeout(resolve, 100));
195
+ const RETRY_INTERVAL = 100;
196
+ const totalAttempts = timeout / RETRY_INTERVAL;
197
+ for (let attempt = 1; attempt <= totalAttempts; attempt++) {
198
+ await new Promise(resolve => setTimeout(resolve, RETRY_INTERVAL));
188
199
  try {
189
200
  return getClientAPI();
190
201
  } catch (e) {
202
+ if (!(attempt % 10)) {
203
+ console.log(`Error in getClientAPI: ${e.message}, attempt ${attempt}/${totalAttempts}`);
204
+ }
191
205
  error = e;
192
206
  }
193
207
  }
@@ -38,7 +38,16 @@ function __runRunAfterScript(...args) {
38
38
  ) {
39
39
  return API_VERSIONS.v4;
40
40
  } else {
41
- throw new Error("Cannot get client API: couldn't detect storybook version");
41
+ const storybookVariablesOnWindow = Object.keys(frameWindow).filter(key =>
42
+ key.includes('STORYBOOK'),
43
+ );
44
+ throw new Error(
45
+ `Cannot get client API: couldn't detect storybook version.${
46
+ storybookVariablesOnWindow.length
47
+ ? ` Found the following storybook variables: ${storybookVariablesOnWindow.join(', ')}`
48
+ : ' - no STORYBOOK variables found in global scope'
49
+ }`,
50
+ );
42
51
  }
43
52
  }
44
53
  function onStoryRendered(callback) {
@@ -181,13 +190,18 @@ function __runRunAfterScript(...args) {
181
190
  throw new Error('Cannot get client API: no frameWindow');
182
191
  }
183
192
 
184
- async function getClientAPIWithRetries() {
193
+ async function getClientAPIWithRetries({timeout = 10000} = {}) {
185
194
  let error = 'Unknown error';
186
- for (let attempt = 1; attempt <= 100; attempt++) {
187
- await new Promise(resolve => setTimeout(resolve, 100));
195
+ const RETRY_INTERVAL = 100;
196
+ const totalAttempts = timeout / RETRY_INTERVAL;
197
+ for (let attempt = 1; attempt <= totalAttempts; attempt++) {
198
+ await new Promise(resolve => setTimeout(resolve, RETRY_INTERVAL));
188
199
  try {
189
200
  return getClientAPI();
190
201
  } catch (e) {
202
+ if (!(attempt % 10)) {
203
+ console.log(`Error in getClientAPI: ${e.message}, attempt ${attempt}/${totalAttempts}`);
204
+ }
191
205
  error = e;
192
206
  }
193
207
  }
@@ -38,7 +38,16 @@ function __runRunBeforeScript(...args) {
38
38
  ) {
39
39
  return API_VERSIONS.v4;
40
40
  } else {
41
- throw new Error("Cannot get client API: couldn't detect storybook version");
41
+ const storybookVariablesOnWindow = Object.keys(frameWindow).filter(key =>
42
+ key.includes('STORYBOOK'),
43
+ );
44
+ throw new Error(
45
+ `Cannot get client API: couldn't detect storybook version.${
46
+ storybookVariablesOnWindow.length
47
+ ? ` Found the following storybook variables: ${storybookVariablesOnWindow.join(', ')}`
48
+ : ' - no STORYBOOK variables found in global scope'
49
+ }`,
50
+ );
42
51
  }
43
52
  }
44
53
  function onStoryRendered(callback) {
@@ -181,13 +190,18 @@ function __runRunBeforeScript(...args) {
181
190
  throw new Error('Cannot get client API: no frameWindow');
182
191
  }
183
192
 
184
- async function getClientAPIWithRetries() {
193
+ async function getClientAPIWithRetries({timeout = 10000} = {}) {
185
194
  let error = 'Unknown error';
186
- for (let attempt = 1; attempt <= 100; attempt++) {
187
- await new Promise(resolve => setTimeout(resolve, 100));
195
+ const RETRY_INTERVAL = 100;
196
+ const totalAttempts = timeout / RETRY_INTERVAL;
197
+ for (let attempt = 1; attempt <= totalAttempts; attempt++) {
198
+ await new Promise(resolve => setTimeout(resolve, RETRY_INTERVAL));
188
199
  try {
189
200
  return getClientAPI();
190
201
  } catch (e) {
202
+ if (!(attempt % 10)) {
203
+ console.log(`Error in getClientAPI: ${e.message}, attempt ${attempt}/${totalAttempts}`);
204
+ }
191
205
  error = e;
192
206
  }
193
207
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applitools/eyes-storybook",
3
- "version": "3.53.4",
3
+ "version": "3.53.6",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "applitools",
@@ -54,14 +54,14 @@
54
54
  "up:framework": "cd test/fixtures/storybook-versions/${APPLITOOLS_FRAMEWORK_VERSION} && npm ci"
55
55
  },
56
56
  "dependencies": {
57
- "@applitools/core": "4.30.0",
58
- "@applitools/driver": "1.20.3",
59
- "@applitools/eyes": "1.31.2",
57
+ "@applitools/core": "4.31.0",
58
+ "@applitools/driver": "1.20.4",
59
+ "@applitools/eyes": "1.32.0",
60
60
  "@applitools/functional-commons": "1.6.0",
61
61
  "@applitools/logger": "2.1.0",
62
62
  "@applitools/monitoring-commons": "1.0.19",
63
- "@applitools/spec-driver-puppeteer": "1.4.23",
64
- "@applitools/ufg-client": "1.16.1",
63
+ "@applitools/spec-driver-puppeteer": "1.4.24",
64
+ "@applitools/ufg-client": "1.16.3",
65
65
  "@applitools/utils": "1.7.7",
66
66
  "boxen": "4.2.0",
67
67
  "chalk": "3.0.0",
@@ -35,7 +35,16 @@ function getClientAPI() {
35
35
  ) {
36
36
  return API_VERSIONS.v4;
37
37
  } else {
38
- throw new Error("Cannot get client API: couldn't detect storybook version");
38
+ const storybookVariablesOnWindow = Object.keys(frameWindow).filter(key =>
39
+ key.includes('STORYBOOK'),
40
+ );
41
+ throw new Error(
42
+ `Cannot get client API: couldn't detect storybook version.${
43
+ storybookVariablesOnWindow.length
44
+ ? ` Found the following storybook variables: ${storybookVariablesOnWindow.join(', ')}`
45
+ : ' - no STORYBOOK variables found in global scope'
46
+ }`,
47
+ );
39
48
  }
40
49
  }
41
50
  function onStoryRendered(callback) {
@@ -178,13 +187,18 @@ function getFrameWindow() {
178
187
  throw new Error('Cannot get client API: no frameWindow');
179
188
  }
180
189
 
181
- async function getClientAPIWithRetries() {
190
+ async function getClientAPIWithRetries({timeout = 10000} = {}) {
182
191
  let error = 'Unknown error';
183
- for (let attempt = 1; attempt <= 100; attempt++) {
184
- await new Promise(resolve => setTimeout(resolve, 100));
192
+ const RETRY_INTERVAL = 100;
193
+ const totalAttempts = timeout / RETRY_INTERVAL;
194
+ for (let attempt = 1; attempt <= totalAttempts; attempt++) {
195
+ await new Promise(resolve => setTimeout(resolve, RETRY_INTERVAL));
185
196
  try {
186
197
  return getClientAPI();
187
198
  } catch (e) {
199
+ if (!(attempt % 10)) {
200
+ console.log(`Error in getClientAPI: ${e.message}, attempt ${attempt}/${totalAttempts}`);
201
+ }
188
202
  error = e;
189
203
  }
190
204
  }
@@ -172,7 +172,7 @@ async function getStories({timeout = DEFAULT_TIMEOUT} = {timeout: DEFAULT_TIMEOU
172
172
 
173
173
  async function _waitForClientAPI() {
174
174
  try {
175
- return getClientAPI();
175
+ return getClientAPI({timeout});
176
176
  } catch (ex) {
177
177
  await delay(100);
178
178
  return _waitForClientAPI();
@@ -43,6 +43,7 @@ const configParams = [
43
43
  'notifyOnCompletion',
44
44
  'batchNotify',
45
45
  'dontCloseBatches',
46
+ 'showBrowserLogs',
46
47
  ];
47
48
 
48
49
  module.exports = {configParams};
@@ -23,7 +23,7 @@ const {extractEnvironment} = require('./extractEnvironment');
23
23
  const {makeCore} = require('@applitools/core');
24
24
  const makeGetStoriesWithConfig = require('./getStoriesWithConfig');
25
25
 
26
- const MAX_RETRIES = 50;
26
+ const MAX_RETRIES = 30;
27
27
  const RETRY_INTERVAL = 1000;
28
28
 
29
29
  async function eyesStorybook({
@@ -237,7 +237,7 @@ async function eyesStorybook({
237
237
  const [getStoriesErr, stories] = await readStoriesWithRetry(MAX_RETRIES);
238
238
 
239
239
  if (getStoriesErr) {
240
- logger.log('Error in getStories:', getStoriesErr);
240
+ logger.log('Error when reading stories:', getStoriesErr);
241
241
  const failMsg = refineErrorMessage({
242
242
  prefix: 'Error when reading stories:',
243
243
  error: getStoriesErr,
@@ -290,13 +290,14 @@ async function eyesStorybook({
290
290
  if (stories?.length > 0 || remainingRetries == 0) {
291
291
  return [getStoriesErr, stories];
292
292
  } else {
293
+ remainingRetries--;
293
294
  if (getStoriesErr) {
294
- logger.log('Error in getStories:', getStoriesErr);
295
+ logger.log('Error in getStories:', getStoriesErr, `, ${remainingRetries} retries are left`);
295
296
  } else {
296
- logger.log(`Got 0 stories, retrying to read stories... ${remainingRetries - 1} are left`);
297
+ logger.log(`Got 0 stories, ${remainingRetries} retries are left`);
297
298
  }
298
299
  await delay(RETRY_INTERVAL);
299
- return await readStoriesWithRetry(remainingRetries - 1);
300
+ return await readStoriesWithRetry(remainingRetries);
300
301
  }
301
302
  }
302
303
  }
@@ -13,9 +13,9 @@ const DOM_SNAPSHOTS_TIMEOUT = 5 * 60 * 1000;
13
13
  const utils = require('@applitools/utils');
14
14
 
15
15
  function makeGetStoryData({logger, takeDomSnapshots, reloadPagePerStory, navigationWaitUntil}) {
16
- return async function getStoryData({story, storyUrl, page}) {
16
+ return async function getStoryData({story, storyUrl, page, pageId = 'mock'}) {
17
17
  const title = getStoryBaselineName(story);
18
- logger.log(`getting data from story`, title);
18
+ logger.log(`[page ${pageId}] getting data from story`, title);
19
19
 
20
20
  const eyesParameters = story.parameters && story.parameters.eyes;
21
21
  if (story.isApi && !reloadPagePerStory) {
@@ -26,9 +26,9 @@ function makeGetStoryData({logger, takeDomSnapshots, reloadPagePerStory, navigat
26
26
  const err = await ptimeoutWithError(
27
27
  page.evaluate(renderStoryWithClientAPI, story.index, story.id),
28
28
  PAGE_EVALUATE_TIMEOUT,
29
- new Error('page evaluate timed out!'),
29
+ new Error(`[page ${pageId}] page evaluate timed out!`),
30
30
  );
31
- logger.log(`[story data] done with page evaluate for story ${title}`);
31
+ logger.log(`[page ${pageId}] done with page evaluate for story ${title}`);
32
32
  err && handleRenderStoryError(err);
33
33
  } catch (ex) {
34
34
  if (ex.message && !ex.message.includes('Eyes could not render stories properly'))
@@ -53,17 +53,17 @@ function makeGetStoryData({logger, takeDomSnapshots, reloadPagePerStory, navigat
53
53
 
54
54
  if (eyesParameters && eyesParameters.runBefore) {
55
55
  await page.evaluate(runRunBeforeScript, story.index).catch(err => {
56
- logger.log(`error during runBefore: ${err}`); // it might be good to aggregate these errors and output them at the end of the run
56
+ logger.log(`[page ${pageId}] error during runBefore: ${err}`); // it might be good to aggregate these errors and output them at the end of the run
57
57
  });
58
58
  }
59
59
 
60
- logger.log(`running takeDomSnapshot(s) for story ${title}`);
60
+ logger.log(`[page ${pageId}] running takeDomSnapshot(s) for story ${title}`);
61
61
  const domSnapshotsPromise = takeDomSnapshots({
62
62
  page,
63
63
  ...storyToCheckSettings({story}),
64
64
  waitBeforeCapture: wait
65
65
  ? async () => {
66
- logger.log(`waiting before screenshot of ${title} ${wait}`);
66
+ logger.log(`[page ${pageId}] waiting before screenshot of ${title} ${wait}`);
67
67
  await waitFor(page, wait);
68
68
  }
69
69
  : undefined,
@@ -72,27 +72,27 @@ function makeGetStoryData({logger, takeDomSnapshots, reloadPagePerStory, navigat
72
72
  const result = await ptimeoutWithError(
73
73
  domSnapshotsPromise,
74
74
  DOM_SNAPSHOTS_TIMEOUT,
75
- new Error(`timeout reached when trying to take DOM for story ${title}`),
75
+ new Error(`[page ${pageId}] timeout reached when trying to take DOM for story ${title}`),
76
76
  );
77
77
 
78
- logger.log(`done getting DOM for story ${title}`);
78
+ logger.log(`[page ${pageId}] done getting DOM for story ${title}`);
79
79
 
80
80
  if (eyesParameters && eyesParameters.runAfter) {
81
81
  await page.evaluate(runRunAfterScript, story.index).catch(err => {
82
- logger.log(`error during runAfter: ${err}`);
82
+ logger.log(`[page ${pageId}] error during runAfter: ${err}`);
83
83
  });
84
84
  }
85
85
 
86
- logger.log(`done getting data from story`, title);
86
+ logger.log(`[page ${pageId}] done getting data from story`, title);
87
87
  return result;
88
88
 
89
89
  async function renderStoryLegacy() {
90
- logger.log(`getting data from story ${storyUrl}`);
90
+ logger.log(`[page ${pageId}] getting data from story ${storyUrl}`);
91
91
  const [err] = await presult(
92
92
  page.goto(storyUrl, {timeout: PAGE_EVALUATE_TIMEOUT, waitUntil: navigationWaitUntil}),
93
93
  );
94
94
  if (err) {
95
- logger.log(`error navigating to story ${storyUrl}`, err);
95
+ logger.log(`[page ${pageId}] error navigating to story ${storyUrl}`, err);
96
96
  throw err;
97
97
  }
98
98
  }
@@ -101,7 +101,7 @@ function makeGetStoryData({logger, takeDomSnapshots, reloadPagePerStory, navigat
101
101
  try {
102
102
  url = new URL(url);
103
103
  } catch (err) {
104
- logger.error('Error during parsing page url', err);
104
+ logger.error(`[page ${pageId}] Error during parsing page url`, err);
105
105
  return false;
106
106
  }
107
107
 
@@ -124,7 +124,7 @@ function makeGetStoryData({logger, takeDomSnapshots, reloadPagePerStory, navigat
124
124
 
125
125
  // TODO (amit): handle this error in the caller (probably renderStories)
126
126
  function handleRenderStoryError(error) {
127
- logger.log(error.message);
127
+ logger.log(`[page ${pageId}] ${error.message}`);
128
128
  const versionMsg = error.version
129
129
  ? ` The detected version of storybook is ${error.version}.`
130
130
  : '';
package/src/initPage.js CHANGED
@@ -16,7 +16,9 @@ function makeInitPage({iframeUrl, config, browser, logger, getTransitiongIntoIE,
16
16
  browserLog({
17
17
  page,
18
18
  onLog: text => {
19
- if (text.match(/\[dom-snapshot\]/)) {
19
+ if (config.showBrowserLogs) {
20
+ logger.log(`tab ${pageId}: ${text}`);
21
+ } else if (text.match(/\[dom-snapshot\]/)) {
20
22
  logger.log(`tab ${pageId}: ${text}`);
21
23
  }
22
24
  },
@@ -2,7 +2,10 @@
2
2
  const getStoryUrl = require('./getStoryUrl');
3
3
  const getStoryBaselineName = require('./getStoryBaselineName');
4
4
  const ora = require('ora');
5
- const {presult} = require('@applitools/functional-commons');
5
+ const {presult, delay} = require('@applitools/functional-commons');
6
+
7
+ const MAX_RETRIES = 30;
8
+ const RETRY_INTERVAL = 1000;
6
9
 
7
10
  function makeRenderStories({
8
11
  getStoryData,
@@ -64,6 +67,7 @@ function makeRenderStories({
64
67
  story,
65
68
  storyUrl,
66
69
  page,
70
+ pageId,
67
71
  }),
68
72
  );
69
73
 
@@ -88,6 +92,7 @@ function makeRenderStories({
88
92
  story,
89
93
  storyUrl,
90
94
  page: newPageObj.page,
95
+ pageId: newPageObj.pageId,
91
96
  }),
92
97
  );
93
98
  error = newError;
@@ -149,7 +154,7 @@ function makeRenderStories({
149
154
 
150
155
  const {pageId, page} = pageObj;
151
156
  logger.log(`[prepareNewPage] new page is ready: ${pageId}`);
152
- const [errorInSanity] = await presult(page.evaluate(getClientAPI));
157
+ const [errorInSanity] = await getClientAPIWithRetry(page, MAX_RETRIES);
153
158
  if (errorInSanity) {
154
159
  logger.log(
155
160
  `[prepareNewPage] new page ${pageId} is corrupted. preparing new page. ${errorInSanity}`,
@@ -163,6 +168,19 @@ function makeRenderStories({
163
168
  newPageIdToAdd = pageId;
164
169
  }
165
170
  };
171
+
172
+ async function getClientAPIWithRetry(page, remainingRetries) {
173
+ const [err] = await presult(page.evaluate(getClientAPI, {timeout: 10000}));
174
+ if (!err || remainingRetries == 0) {
175
+ return [err];
176
+ } else if (err) {
177
+ logger.log(
178
+ `Error in getClientAPI: ${err.message} retrying... ${remainingRetries - 1} are left`,
179
+ );
180
+ await delay(RETRY_INTERVAL);
181
+ return await getClientAPIWithRetry(page, remainingRetries - 1);
182
+ }
183
+ }
166
184
  }
167
185
 
168
186
  module.exports = makeRenderStories;