@applitools/eyes-storybook 3.31.1 → 3.31.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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,19 @@
3
3
  ## Unreleased
4
4
 
5
5
 
6
+ ## 3.31.3 - 2023/3/14
7
+
8
+ ### Features
9
+ ### Bug fixes
10
+ - Update internal dependencies
11
+
12
+ ## 3.31.2 - 2023/3/9
13
+
14
+ ### Features
15
+ - Add support for storybook 7
16
+ ### Bug fixes
17
+ - Support running Storybook dev server in Node.js v18
18
+
6
19
  ## 3.31.1 - 2023/2/21
7
20
 
8
21
  ### Features
@@ -13,12 +13,12 @@ function __getClientAPI(...args) {
13
13
  function getClientAPI() {
14
14
  const frameWindow = getFrameWindow();
15
15
  const clientAPI = frameWindow.__STORYBOOK_CLIENT_API__;
16
- const addons = frameWindow.__STORYBOOK_ADDONS;
16
+ const addons = frameWindow.__STORYBOOK_ADDONS || frameWindow.__STORYBOOK_ADDONS_PREVIEW;
17
17
 
18
18
  return getAPI(getStorybookVersion());
19
19
 
20
20
  function getStorybookVersion() {
21
- const addons = frameWindow.__STORYBOOK_ADDONS;
21
+ const addonsForV4 = frameWindow.__STORYBOOK_ADDONS;
22
22
 
23
23
  if (frameWindow.__STORYBOOK_PREVIEW__) {
24
24
  return API_VERSIONS.v6_4;
@@ -27,11 +27,11 @@ function __getClientAPI(...args) {
27
27
  } else if (frameWindow.__STORYBOOK_CLIENT_API__ && frameWindow.__STORYBOOK_CLIENT_API__.raw) {
28
28
  return API_VERSIONS.v5;
29
29
  } else if (
30
- addons &&
31
- addons.channel &&
32
- addons.channel._listeners &&
33
- addons.channel._listeners.setCurrentStory &&
34
- addons.channel._listeners.setCurrentStory[0]
30
+ addonsForV4 &&
31
+ addonsForV4.channel &&
32
+ addonsForV4.channel._listeners &&
33
+ addonsForV4.channel._listeners.setCurrentStory &&
34
+ addonsForV4.channel._listeners.setCurrentStory[0]
35
35
  ) {
36
36
  return API_VERSIONS.v4;
37
37
  } else {
@@ -43,6 +43,15 @@ function __getClientAPI(...args) {
43
43
  addons.channel.once('storyRendered', () => {
44
44
  setTimeout(callback, 0);
45
45
  });
46
+ addons.channel.once('playFunctionThrewException', () => {
47
+ setTimeout(callback, 0);
48
+ });
49
+ addons.channel.once('storyErrored', () => {
50
+ setTimeout(callback, 0);
51
+ });
52
+ addons.channel.once('storyThrewException', () => {
53
+ setTimeout(callback, 0);
54
+ });
46
55
  } else {
47
56
  callback();
48
57
  }
@@ -110,9 +119,14 @@ function __getClientAPI(...args) {
110
119
  await clientAPI.storyStore.cacheAllCSFFiles();
111
120
  storyId = clientAPI.raw()[i].id;
112
121
  }
113
- frameWindow.__STORYBOOK_PREVIEW__.urlStore.setSelection({
114
- storyId,
115
- });
122
+ if (frameWindow.__STORYBOOK_PREVIEW__.urlStore) {
123
+ frameWindow.__STORYBOOK_PREVIEW__.urlStore.setSelection({
124
+ storyId,
125
+ });
126
+ } else {
127
+ // storybook v7
128
+ frameWindow.__STORYBOOK_PREVIEW__.selectionStore.setSelection({storyId});
129
+ }
116
130
  await frameWindow.__STORYBOOK_PREVIEW__.renderSelection();
117
131
  },
118
132
  onStoryRendered,
@@ -13,12 +13,12 @@ function __getStories(...args) {
13
13
  function getClientAPI() {
14
14
  const frameWindow = getFrameWindow();
15
15
  const clientAPI = frameWindow.__STORYBOOK_CLIENT_API__;
16
- const addons = frameWindow.__STORYBOOK_ADDONS;
16
+ const addons = frameWindow.__STORYBOOK_ADDONS || frameWindow.__STORYBOOK_ADDONS_PREVIEW;
17
17
 
18
18
  return getAPI(getStorybookVersion());
19
19
 
20
20
  function getStorybookVersion() {
21
- const addons = frameWindow.__STORYBOOK_ADDONS;
21
+ const addonsForV4 = frameWindow.__STORYBOOK_ADDONS;
22
22
 
23
23
  if (frameWindow.__STORYBOOK_PREVIEW__) {
24
24
  return API_VERSIONS.v6_4;
@@ -27,11 +27,11 @@ function __getStories(...args) {
27
27
  } else if (frameWindow.__STORYBOOK_CLIENT_API__ && frameWindow.__STORYBOOK_CLIENT_API__.raw) {
28
28
  return API_VERSIONS.v5;
29
29
  } else if (
30
- addons &&
31
- addons.channel &&
32
- addons.channel._listeners &&
33
- addons.channel._listeners.setCurrentStory &&
34
- addons.channel._listeners.setCurrentStory[0]
30
+ addonsForV4 &&
31
+ addonsForV4.channel &&
32
+ addonsForV4.channel._listeners &&
33
+ addonsForV4.channel._listeners.setCurrentStory &&
34
+ addonsForV4.channel._listeners.setCurrentStory[0]
35
35
  ) {
36
36
  return API_VERSIONS.v4;
37
37
  } else {
@@ -43,6 +43,15 @@ function __getStories(...args) {
43
43
  addons.channel.once('storyRendered', () => {
44
44
  setTimeout(callback, 0);
45
45
  });
46
+ addons.channel.once('playFunctionThrewException', () => {
47
+ setTimeout(callback, 0);
48
+ });
49
+ addons.channel.once('storyErrored', () => {
50
+ setTimeout(callback, 0);
51
+ });
52
+ addons.channel.once('storyThrewException', () => {
53
+ setTimeout(callback, 0);
54
+ });
46
55
  } else {
47
56
  callback();
48
57
  }
@@ -110,9 +119,14 @@ function __getStories(...args) {
110
119
  await clientAPI.storyStore.cacheAllCSFFiles();
111
120
  storyId = clientAPI.raw()[i].id;
112
121
  }
113
- frameWindow.__STORYBOOK_PREVIEW__.urlStore.setSelection({
114
- storyId,
115
- });
122
+ if (frameWindow.__STORYBOOK_PREVIEW__.urlStore) {
123
+ frameWindow.__STORYBOOK_PREVIEW__.urlStore.setSelection({
124
+ storyId,
125
+ });
126
+ } else {
127
+ // storybook v7
128
+ frameWindow.__STORYBOOK_PREVIEW__.selectionStore.setSelection({storyId});
129
+ }
116
130
  await frameWindow.__STORYBOOK_PREVIEW__.renderSelection();
117
131
  },
118
132
  onStoryRendered,
@@ -13,12 +13,12 @@ function __renderStoryWithClientAPI(...args) {
13
13
  function getClientAPI() {
14
14
  const frameWindow = getFrameWindow();
15
15
  const clientAPI = frameWindow.__STORYBOOK_CLIENT_API__;
16
- const addons = frameWindow.__STORYBOOK_ADDONS;
16
+ const addons = frameWindow.__STORYBOOK_ADDONS || frameWindow.__STORYBOOK_ADDONS_PREVIEW;
17
17
 
18
18
  return getAPI(getStorybookVersion());
19
19
 
20
20
  function getStorybookVersion() {
21
- const addons = frameWindow.__STORYBOOK_ADDONS;
21
+ const addonsForV4 = frameWindow.__STORYBOOK_ADDONS;
22
22
 
23
23
  if (frameWindow.__STORYBOOK_PREVIEW__) {
24
24
  return API_VERSIONS.v6_4;
@@ -27,11 +27,11 @@ function __renderStoryWithClientAPI(...args) {
27
27
  } else if (frameWindow.__STORYBOOK_CLIENT_API__ && frameWindow.__STORYBOOK_CLIENT_API__.raw) {
28
28
  return API_VERSIONS.v5;
29
29
  } else if (
30
- addons &&
31
- addons.channel &&
32
- addons.channel._listeners &&
33
- addons.channel._listeners.setCurrentStory &&
34
- addons.channel._listeners.setCurrentStory[0]
30
+ addonsForV4 &&
31
+ addonsForV4.channel &&
32
+ addonsForV4.channel._listeners &&
33
+ addonsForV4.channel._listeners.setCurrentStory &&
34
+ addonsForV4.channel._listeners.setCurrentStory[0]
35
35
  ) {
36
36
  return API_VERSIONS.v4;
37
37
  } else {
@@ -43,6 +43,15 @@ function __renderStoryWithClientAPI(...args) {
43
43
  addons.channel.once('storyRendered', () => {
44
44
  setTimeout(callback, 0);
45
45
  });
46
+ addons.channel.once('playFunctionThrewException', () => {
47
+ setTimeout(callback, 0);
48
+ });
49
+ addons.channel.once('storyErrored', () => {
50
+ setTimeout(callback, 0);
51
+ });
52
+ addons.channel.once('storyThrewException', () => {
53
+ setTimeout(callback, 0);
54
+ });
46
55
  } else {
47
56
  callback();
48
57
  }
@@ -110,9 +119,14 @@ function __renderStoryWithClientAPI(...args) {
110
119
  await clientAPI.storyStore.cacheAllCSFFiles();
111
120
  storyId = clientAPI.raw()[i].id;
112
121
  }
113
- frameWindow.__STORYBOOK_PREVIEW__.urlStore.setSelection({
114
- storyId,
115
- });
122
+ if (frameWindow.__STORYBOOK_PREVIEW__.urlStore) {
123
+ frameWindow.__STORYBOOK_PREVIEW__.urlStore.setSelection({
124
+ storyId,
125
+ });
126
+ } else {
127
+ // storybook v7
128
+ frameWindow.__STORYBOOK_PREVIEW__.selectionStore.setSelection({storyId});
129
+ }
116
130
  await frameWindow.__STORYBOOK_PREVIEW__.renderSelection();
117
131
  },
118
132
  onStoryRendered,
@@ -13,12 +13,12 @@ function __runRunAfterScript(...args) {
13
13
  function getClientAPI() {
14
14
  const frameWindow = getFrameWindow();
15
15
  const clientAPI = frameWindow.__STORYBOOK_CLIENT_API__;
16
- const addons = frameWindow.__STORYBOOK_ADDONS;
16
+ const addons = frameWindow.__STORYBOOK_ADDONS || frameWindow.__STORYBOOK_ADDONS_PREVIEW;
17
17
 
18
18
  return getAPI(getStorybookVersion());
19
19
 
20
20
  function getStorybookVersion() {
21
- const addons = frameWindow.__STORYBOOK_ADDONS;
21
+ const addonsForV4 = frameWindow.__STORYBOOK_ADDONS;
22
22
 
23
23
  if (frameWindow.__STORYBOOK_PREVIEW__) {
24
24
  return API_VERSIONS.v6_4;
@@ -27,11 +27,11 @@ function __runRunAfterScript(...args) {
27
27
  } else if (frameWindow.__STORYBOOK_CLIENT_API__ && frameWindow.__STORYBOOK_CLIENT_API__.raw) {
28
28
  return API_VERSIONS.v5;
29
29
  } else if (
30
- addons &&
31
- addons.channel &&
32
- addons.channel._listeners &&
33
- addons.channel._listeners.setCurrentStory &&
34
- addons.channel._listeners.setCurrentStory[0]
30
+ addonsForV4 &&
31
+ addonsForV4.channel &&
32
+ addonsForV4.channel._listeners &&
33
+ addonsForV4.channel._listeners.setCurrentStory &&
34
+ addonsForV4.channel._listeners.setCurrentStory[0]
35
35
  ) {
36
36
  return API_VERSIONS.v4;
37
37
  } else {
@@ -43,6 +43,15 @@ function __runRunAfterScript(...args) {
43
43
  addons.channel.once('storyRendered', () => {
44
44
  setTimeout(callback, 0);
45
45
  });
46
+ addons.channel.once('playFunctionThrewException', () => {
47
+ setTimeout(callback, 0);
48
+ });
49
+ addons.channel.once('storyErrored', () => {
50
+ setTimeout(callback, 0);
51
+ });
52
+ addons.channel.once('storyThrewException', () => {
53
+ setTimeout(callback, 0);
54
+ });
46
55
  } else {
47
56
  callback();
48
57
  }
@@ -110,9 +119,14 @@ function __runRunAfterScript(...args) {
110
119
  await clientAPI.storyStore.cacheAllCSFFiles();
111
120
  storyId = clientAPI.raw()[i].id;
112
121
  }
113
- frameWindow.__STORYBOOK_PREVIEW__.urlStore.setSelection({
114
- storyId,
115
- });
122
+ if (frameWindow.__STORYBOOK_PREVIEW__.urlStore) {
123
+ frameWindow.__STORYBOOK_PREVIEW__.urlStore.setSelection({
124
+ storyId,
125
+ });
126
+ } else {
127
+ // storybook v7
128
+ frameWindow.__STORYBOOK_PREVIEW__.selectionStore.setSelection({storyId});
129
+ }
116
130
  await frameWindow.__STORYBOOK_PREVIEW__.renderSelection();
117
131
  },
118
132
  onStoryRendered,
@@ -13,12 +13,12 @@ function __runRunBeforeScript(...args) {
13
13
  function getClientAPI() {
14
14
  const frameWindow = getFrameWindow();
15
15
  const clientAPI = frameWindow.__STORYBOOK_CLIENT_API__;
16
- const addons = frameWindow.__STORYBOOK_ADDONS;
16
+ const addons = frameWindow.__STORYBOOK_ADDONS || frameWindow.__STORYBOOK_ADDONS_PREVIEW;
17
17
 
18
18
  return getAPI(getStorybookVersion());
19
19
 
20
20
  function getStorybookVersion() {
21
- const addons = frameWindow.__STORYBOOK_ADDONS;
21
+ const addonsForV4 = frameWindow.__STORYBOOK_ADDONS;
22
22
 
23
23
  if (frameWindow.__STORYBOOK_PREVIEW__) {
24
24
  return API_VERSIONS.v6_4;
@@ -27,11 +27,11 @@ function __runRunBeforeScript(...args) {
27
27
  } else if (frameWindow.__STORYBOOK_CLIENT_API__ && frameWindow.__STORYBOOK_CLIENT_API__.raw) {
28
28
  return API_VERSIONS.v5;
29
29
  } else if (
30
- addons &&
31
- addons.channel &&
32
- addons.channel._listeners &&
33
- addons.channel._listeners.setCurrentStory &&
34
- addons.channel._listeners.setCurrentStory[0]
30
+ addonsForV4 &&
31
+ addonsForV4.channel &&
32
+ addonsForV4.channel._listeners &&
33
+ addonsForV4.channel._listeners.setCurrentStory &&
34
+ addonsForV4.channel._listeners.setCurrentStory[0]
35
35
  ) {
36
36
  return API_VERSIONS.v4;
37
37
  } else {
@@ -43,6 +43,15 @@ function __runRunBeforeScript(...args) {
43
43
  addons.channel.once('storyRendered', () => {
44
44
  setTimeout(callback, 0);
45
45
  });
46
+ addons.channel.once('playFunctionThrewException', () => {
47
+ setTimeout(callback, 0);
48
+ });
49
+ addons.channel.once('storyErrored', () => {
50
+ setTimeout(callback, 0);
51
+ });
52
+ addons.channel.once('storyThrewException', () => {
53
+ setTimeout(callback, 0);
54
+ });
46
55
  } else {
47
56
  callback();
48
57
  }
@@ -110,9 +119,14 @@ function __runRunBeforeScript(...args) {
110
119
  await clientAPI.storyStore.cacheAllCSFFiles();
111
120
  storyId = clientAPI.raw()[i].id;
112
121
  }
113
- frameWindow.__STORYBOOK_PREVIEW__.urlStore.setSelection({
114
- storyId,
115
- });
122
+ if (frameWindow.__STORYBOOK_PREVIEW__.urlStore) {
123
+ frameWindow.__STORYBOOK_PREVIEW__.urlStore.setSelection({
124
+ storyId,
125
+ });
126
+ } else {
127
+ // storybook v7
128
+ frameWindow.__STORYBOOK_PREVIEW__.selectionStore.setSelection({storyId});
129
+ }
116
130
  await frameWindow.__STORYBOOK_PREVIEW__.renderSelection();
117
131
  },
118
132
  onStoryRendered,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applitools/eyes-storybook",
3
- "version": "3.31.1",
3
+ "version": "3.31.3",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "applitools",
@@ -35,28 +35,27 @@
35
35
  "build:heavy": "node scripts/bitmap.js",
36
36
  "test": "yarn build && yarn test:mocha && yarn lint",
37
37
  "test:sanity": "yarn test:unit && yarn test:it",
38
- "test:mocha": "yarn test:unit && yarn test:it && yarn test:e2e",
38
+ "test:mocha": "mocha --no-timeouts --trace-warnings 'test/{unit,it,e2e}/*.test.js'",
39
39
  "test:unit": "mocha --no-timeouts --trace-warnings 'test/unit/*.test.js'",
40
40
  "test:it": "mocha --no-timeouts --trace-warnings 'test/it/*.test.js'",
41
41
  "test:versions": "yarn build && yarn test:e2e:versions && yarn lint",
42
42
  "test:e2e": "mocha --no-timeouts --trace-warnings 'test/e2e/*.e2e.test.js'",
43
- "test:e2e:versions": "npx mocha --no-timeouts --trace-warnings --require test/fixtures/storybook-versions/mochaHooks.js test/e2e/*.e2e.versions.test.js",
44
- "test:e2e:versions_local": "STORYBOOK_VERSION=latest npx mocha --no-timeouts --trace-warnings --require test/fixtures/storybook-versions/mochaHooks.js test/e2e/*.e2e.versions.test.js",
43
+ "test:e2e:versions": "npx mocha --no-timeouts --trace-warnings --require test/fixtures/storybook-versions/mochaHooks.js test/versions/*.e2e.versions.test.js",
44
+ "test:e2e:versions_local": "STORYBOOK_VERSION=latest npx mocha --no-timeouts --trace-warnings --require test/fixtures/storybook-versions/mochaHooks.js test/versions/*.e2e.versions.test.js",
45
45
  "storybook": "start-storybook -c test/fixtures/appWithStorybook -p 9001 -s test/fixtures",
46
46
  "storybook:httpHeaders": "start-storybook -c test/fixtures/appWithCustomHttpHeaders -p 9007",
47
47
  "storybook:jslayout": "start-storybook -c test/fixtures/jsLayoutStorybookLocal -p 9001 -s test/fixtures",
48
- "storybook:csf": "yarn storybook:csf-service && start-storybook -c test/fixtures/storybookCSF/.storybook-temp -p 9001",
49
- "storybook:csf-service": "cp -r test/fixtures/storybookCSF/.storybook/. test/fixtures/storybookCSF/.storybook-temp && rm test/fixtures/storybookCSF/.storybook-temp/config.js",
48
+ "storybook:csf": "start-storybook -c test/fixtures/storybook-versions/latest/.storybook -p 9001",
50
49
  "storybook:heavy": "start-storybook -c test/fixtures/heavyStorybook -p 9002 -s test/fixtures",
51
50
  "storybook:zeroStories": "start-storybook -c test/fixtures/zeroStoriesRetry -p 9003 -s test/fixtures",
52
- "storybook:csf-v7": "start-storybook -c test/fixtures/storybookCSFV7/.storybook/ -p 9004 -s test/fixtures/",
51
+ "storybook:csf-storyStore7": "start-storybook -c test/fixtures/storybook-storyStore7/.storybook/ -p 9004 -s test/fixtures/",
53
52
  "eyes-storybook": "node bin/eyes-storybook.js -f test/fixtures/applitools.config.js",
54
53
  "eyes-storybook:jslayout": "node bin/eyes-storybook.js -f test/e2e/happy-config/layout-breakpoints-local.config.js",
55
54
  "eyes-storybook:heavy": "node bin/eyes-storybook.js -f test/fixtures/heavyStorybook/applitools.config.js",
56
55
  "eyes-storybook:configured": "node bin/eyes-storybook.js -f scripts/preconfigured.config.js",
57
56
  "eyes-storybook:zeroStories": "node bin/eyes-storybook.js -f test/fixtures/zeroStoriesRetry/applitools.config.js",
58
57
  "eyes-storybook:httpHeaders": "node bin/eyes-storybook.js -f test/fixtures/appWithCustomHttpHeaders/applitools.config.js",
59
- "eyes-storybook:csf-v7": "node bin/eyes-storybook.js -f test/fixtures/storybookCSFV7/applitools.config.js",
58
+ "eyes-storybook:csf-storyStore7": "node bin/eyes-storybook.js -f test/fixtures/storybook-storyStore7/applitools.config.js",
60
59
  "changelog": "git changelog -x -p -f v$npm_package_version > History.md && git add ./History.md && git commit -am 'changelog'",
61
60
  "changelog:init": "git config changelog.format \"* %s [[%h]($(echo $npm_package_repository_url|cut -d+ -f2|cut -d. -f1-2)/commit/%H)]\"",
62
61
  "changelog:install": "sudo apt-get install git-extras",
@@ -66,7 +65,7 @@
66
65
  "postinstall": "node src/postinstall",
67
66
  "preversion": "bongo preversion --verifyPendingChanges",
68
67
  "version": "bongo version --withPendingChanges",
69
- "postversion": "bongo postversion --skip-release-notification"
68
+ "postversion": "bongo postversion"
70
69
  },
71
70
  "husky": {
72
71
  "hooks": {
@@ -74,15 +73,15 @@
74
73
  }
75
74
  },
76
75
  "dependencies": {
77
- "@applitools/core": "2.3.6",
78
- "@applitools/driver": "1.11.32",
76
+ "@applitools/core": "2.4.0",
77
+ "@applitools/driver": "1.11.36",
79
78
  "@applitools/functional-commons": "1.6.0",
80
- "@applitools/logger": "1.1.46",
79
+ "@applitools/logger": "1.1.47",
81
80
  "@applitools/monitoring-commons": "1.0.19",
82
- "@applitools/spec-driver-puppeteer": "1.1.44",
83
- "@applitools/test-server": "1.1.26",
84
- "@applitools/ufg-client": "1.1.26",
85
- "@applitools/utils": "1.3.30",
81
+ "@applitools/spec-driver-puppeteer": "1.1.48",
82
+ "@applitools/test-server": "1.1.27",
83
+ "@applitools/ufg-client": "1.2.2",
84
+ "@applitools/utils": "1.3.31",
86
85
  "boxen": "4.2.0",
87
86
  "chalk": "3.0.0",
88
87
  "detect-port": "1.3.0",
@@ -95,7 +94,7 @@
95
94
  "yargs": "15.4.1"
96
95
  },
97
96
  "devDependencies": {
98
- "@applitools/bongo": "^2.2.5",
97
+ "@applitools/bongo": "^3.0.1",
99
98
  "@applitools/sdk-shared": "0.9.15",
100
99
  "@applitools/snaptdout": "^1.0.1",
101
100
  "@storybook/addon-interactions": "^6.4.18",
@@ -10,12 +10,12 @@ const API_VERSIONS = {
10
10
  function getClientAPI() {
11
11
  const frameWindow = getFrameWindow();
12
12
  const clientAPI = frameWindow.__STORYBOOK_CLIENT_API__;
13
- const addons = frameWindow.__STORYBOOK_ADDONS;
13
+ const addons = frameWindow.__STORYBOOK_ADDONS || frameWindow.__STORYBOOK_ADDONS_PREVIEW;
14
14
 
15
15
  return getAPI(getStorybookVersion());
16
16
 
17
17
  function getStorybookVersion() {
18
- const addons = frameWindow.__STORYBOOK_ADDONS;
18
+ const addonsForV4 = frameWindow.__STORYBOOK_ADDONS;
19
19
 
20
20
  if (frameWindow.__STORYBOOK_PREVIEW__) {
21
21
  return API_VERSIONS.v6_4;
@@ -24,11 +24,11 @@ function getClientAPI() {
24
24
  } else if (frameWindow.__STORYBOOK_CLIENT_API__ && frameWindow.__STORYBOOK_CLIENT_API__.raw) {
25
25
  return API_VERSIONS.v5;
26
26
  } else if (
27
- addons &&
28
- addons.channel &&
29
- addons.channel._listeners &&
30
- addons.channel._listeners.setCurrentStory &&
31
- addons.channel._listeners.setCurrentStory[0]
27
+ addonsForV4 &&
28
+ addonsForV4.channel &&
29
+ addonsForV4.channel._listeners &&
30
+ addonsForV4.channel._listeners.setCurrentStory &&
31
+ addonsForV4.channel._listeners.setCurrentStory[0]
32
32
  ) {
33
33
  return API_VERSIONS.v4;
34
34
  } else {
@@ -40,6 +40,15 @@ function getClientAPI() {
40
40
  addons.channel.once('storyRendered', () => {
41
41
  setTimeout(callback, 0);
42
42
  });
43
+ addons.channel.once('playFunctionThrewException', () => {
44
+ setTimeout(callback, 0);
45
+ });
46
+ addons.channel.once('storyErrored', () => {
47
+ setTimeout(callback, 0);
48
+ });
49
+ addons.channel.once('storyThrewException', () => {
50
+ setTimeout(callback, 0);
51
+ });
43
52
  } else {
44
53
  callback();
45
54
  }
@@ -107,9 +116,14 @@ function getClientAPI() {
107
116
  await clientAPI.storyStore.cacheAllCSFFiles();
108
117
  storyId = clientAPI.raw()[i].id;
109
118
  }
110
- frameWindow.__STORYBOOK_PREVIEW__.urlStore.setSelection({
111
- storyId,
112
- });
119
+ if (frameWindow.__STORYBOOK_PREVIEW__.urlStore) {
120
+ frameWindow.__STORYBOOK_PREVIEW__.urlStore.setSelection({
121
+ storyId,
122
+ });
123
+ } else {
124
+ // storybook v7
125
+ frameWindow.__STORYBOOK_PREVIEW__.selectionStore.setSelection({storyId});
126
+ }
113
127
  await frameWindow.__STORYBOOK_PREVIEW__.renderSelection();
114
128
  },
115
129
  onStoryRendered,
@@ -133,6 +133,7 @@ async function eyesStorybook({
133
133
  getChromeEmulationDevices: client.getChromeEmulationDevices,
134
134
  getIOSDevices: client.getIOSDevices,
135
135
  },
136
+ showLogs: config.showLogs,
136
137
  });
137
138
  return result;
138
139
  };
@@ -124,8 +124,7 @@ function makeRenderStories({
124
124
 
125
125
  function didTestPass({resultsOrErr}) {
126
126
  return (
127
- resultsOrErr.constructor &&
128
- resultsOrErr.constructor.name !== 'Error' &&
127
+ Array.isArray(resultsOrErr) &&
129
128
  resultsOrErr.every(r => !r.isDifferent && !r.isAborted && !r.isNew)
130
129
  );
131
130
  }
@@ -2,6 +2,7 @@
2
2
  const {resolve} = require('path');
3
3
  const ora = require('ora');
4
4
  const StorybookConnector = require('./storybookConnector');
5
+ const fs = require('fs');
5
6
 
6
7
  async function startStorybookServer({
7
8
  packagePath,
@@ -14,7 +15,14 @@ async function startStorybookServer({
14
15
  startStorybookServerTimeout,
15
16
  }) {
16
17
  const isWindows = process.platform.startsWith('win');
17
- const storybookPath = resolve(packagePath, 'node_modules/.bin/start-storybook');
18
+ let storybookPath, sbArg;
19
+
20
+ if (fs.existsSync(resolve(packagePath, 'node_modules/.bin/sb'))) {
21
+ storybookPath = resolve(packagePath, 'node_modules/.bin/sb');
22
+ sbArg = 'dev';
23
+ } else {
24
+ storybookPath = resolve(packagePath, 'node_modules/.bin/start-storybook');
25
+ }
18
26
 
19
27
  const storybookConnector = new StorybookConnector({
20
28
  storybookPath,
@@ -24,6 +32,7 @@ async function startStorybookServer({
24
32
  storybookStaticDir,
25
33
  isWindows,
26
34
  logger,
35
+ sbArg,
27
36
  });
28
37
 
29
38
  if (showStorybookOutput) {
@@ -12,6 +12,7 @@ class StorybookConnector extends EventEmitter {
12
12
  storybookStaticDir,
13
13
  isWindows,
14
14
  logger,
15
+ sbArg,
15
16
  }) {
16
17
  super();
17
18
  this._storybookPath = `${storybookPath}${isWindows ? '.cmd' : ''}`;
@@ -21,6 +22,7 @@ class StorybookConnector extends EventEmitter {
21
22
  this._storybookStaticDir = storybookStaticDir;
22
23
  this._isWindows = isWindows;
23
24
  this._logger = logger;
25
+ this._sbArg = sbArg;
24
26
 
25
27
  this._childProcess = null;
26
28
  this._version = 5;
@@ -114,8 +116,18 @@ class StorybookConnector extends EventEmitter {
114
116
  if (version >= 4) {
115
117
  args.push('--ci');
116
118
  }
119
+ if (this._sbArg) {
120
+ args.unshift(this._sbArg);
121
+ }
117
122
  this._logger.log(`${this._storybookPath} ${args.join(' ')}`);
118
- this._childProcess = spawn(this._storybookPath, args, {detached: false});
123
+ const spawnOptions = {detached: false};
124
+
125
+ // Storybook has an issue when running with Node.js v18 - https://github.com/storybookjs/storybook/issues/20482
126
+ if (parseInt(process.versions.node) > 16) {
127
+ spawnOptions.env = {...process.env, NODE_OPTIONS: '--openssl-legacy-provider'};
128
+ }
129
+
130
+ this._childProcess = spawn(this._storybookPath, args, spawnOptions);
119
131
  this._addListeners();
120
132
 
121
133
  this._childProcess.once('exit', code => {