@applitools/eyes-storybook 3.23.0 → 3.25.1

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,28 @@
3
3
  ## Unreleased
4
4
 
5
5
 
6
+ ## 3.25.1 - 2021/10/20
7
+
8
+ - updated to @applitools/eyes-puppeteer@1.8.4 (from 1.8.3)
9
+ - updated to @applitools/eyes-sdk-core@12.23.18 (from 12.23.17)
10
+ - updated to @applitools/visual-grid-client@15.8.37 (from 15.8.36)
11
+
12
+ ## 3.25.0 - 2021/10/18
13
+
14
+ - updated to @applitools/driver@1.2.6 (from 1.1.3)
15
+ - updated to @applitools/eyes-puppeteer@1.8.3 (from 1.8.2)
16
+ - updated to @applitools/eyes-sdk-core@12.23.17 (from 12.23.0)
17
+ - updated to @applitools/test-server@1.0.5 (from 1.0.4)
18
+ - updated to @applitools/visual-grid-client@15.8.36 (from 15.8.21)
19
+
20
+ ## 3.24.0 - 2021/8/23
21
+
22
+ - add `startStorybookServerTimeout` config param
23
+
24
+ ## 3.23.1 - 2021/8/23
25
+
26
+ - add `visualGridOptions`, `useDom`, and `enablePatterns` config params
27
+
6
28
  ## 3.23.0 - 2021/8/17
7
29
 
8
30
  - add `sendDom` config param
package/README.md CHANGED
@@ -187,6 +187,7 @@ In addition to command-line arguments, it's possible to define the following con
187
187
  | `accessibilityValidation` | undefined | An object that specifies the accessibility level and guidelines version to use for the screenshots. Possible values for **level** are `None`, `AA` and `AAA`, and possible values for **guidelinesVersion** are `WCAG_2_0` and `WCAG_2_1`. For example: `{level: 'AA', guidelinesVersion: 'WCAG_2_0'}`. For more information, see [per component configuration - accessibilityValidation](#accessibilityValidation)|
188
188
  |`layoutBreakpoints`| undefined | When set to `true`, a snapshot of the DOM will be taken once for each browser/device size in the `browser` configuration. For optimization purposes, an array of numbers can be passed. The DOM snapshot will be taken once for every **width** in the array. For more information, see [per component configuration - layoutBreakpoints](#layoutBreakpoints)|
189
189
  |`sendDom`| true | A flag to specify whether a capture of DOM and CSS should be taken when rendering the screenshot. The default value is true. This should only be modified to troubleshoot unexpected behavior, and not for normal production use. For more information, see [per component configuration - sendDom](#sendDom)|
190
+ | `visualGridOptions` | undefined | An object that specifies options to configure renderings on the Ultrafast grid. See more information [per component configuration - visualGridOptions](#visualgridoptions) |
190
191
 
191
192
  There are 2 ways to specify test configuration:
192
193
 
@@ -664,6 +665,68 @@ storiesOf('Components with ignoreDisplacements', module)
664
665
  });
665
666
  ```
666
667
 
668
+ ### `sendDom`
669
+
670
+ ```js
671
+ storiesOf('Components', module)
672
+ .add(
673
+ 'Some story ',
674
+ () =>
675
+ <div>Some Story</div>, {
676
+ eyes: {
677
+ sendDom: false
678
+ }
679
+ })
680
+ ```
681
+
682
+ ### `visualGridOptions`
683
+
684
+ An object that specifies options to configure renderings on the Ultrafast grid.
685
+ Available options:
686
+
687
+ * `polyfillAdoptedStyleSheets`: Creates a polyfill when the DOM contains `adoptedStyleSheets` ([reference](https://developers.google.com/web/updates/2019/02/constructable-stylesheets)) for browsers that don't support it (It is currently supported only in Chrome). When `true`, those browsers will successfully include the css as inline style tags. When `false`, the css will not be included. When `undefined`, an error will be thrown with a message stating that this feature is not supported in the desired browser.
688
+ * `ieV2`: Use IE environment v2 in the UFG.
689
+
690
+ ```js
691
+ storiesOf('Components', module)
692
+ .add(
693
+ 'Some story ',
694
+ () =>
695
+ <div>Some Story</div>, {
696
+ eyes: {
697
+ visualGridOptions: {
698
+ polyfillAdoptedStyleSheets: true,
699
+ ieV2: true
700
+ }
701
+ }
702
+ })
703
+ ```
704
+
705
+
706
+
707
+ ### `scriptHooks`
708
+
709
+ A set of scripts to be run by the browser during the rendering. It is intended to be used as a means to alter the page's state and structure at the time of rendering.
710
+ An object with the following properties:
711
+
712
+ #### beforeCaptureScreenshot
713
+ A script that runs after the page is loaded but before taking the screenshot. For example:
714
+
715
+
716
+ ```js
717
+ storiesOf('Components', module)
718
+ .add(
719
+ 'Some story',
720
+ () =>
721
+ <div>Some Story</div>, {
722
+ eyes: {
723
+ scriptHooks: {
724
+ beforeCaptureScreenshot: "document.body.style.backgroundColor = 'gold'"
725
+ }
726
+ }
727
+ })
728
+ ```
729
+
667
730
  ## Parameters that cannot be set as an [advanced configuration](#advanced-configuration)
668
731
 
669
732
  ### `runBefore` and `runAfter` functions
@@ -722,29 +785,6 @@ For example, reverting back to the original background color that was changed by
722
785
  })
723
786
  ```
724
787
 
725
- ### `scriptHooks`
726
-
727
- A set of scripts to be run by the browser during the rendering. It is intended to be used as a means to alter the page's state and structure at the time of rendering.
728
- An object with the following properties:
729
-
730
- #### beforeCaptureScreenshot
731
- A script that runs after the page is loaded but before taking the screenshot. For example:
732
-
733
-
734
- ```js
735
- storiesOf('Components', module)
736
- .add(
737
- 'Some story',
738
- () =>
739
- <div>Some Story</div>, {
740
- eyes: {
741
- scriptHooks: {
742
- beforeCaptureScreenshot: "document.body.style.backgroundColor = 'gold'"
743
- }
744
- }
745
- })
746
- ```
747
-
748
788
  ### `layoutBreakpoints`
749
789
 
750
790
  ```js
@@ -767,20 +807,6 @@ An object with the following properties:
767
807
  })
768
808
  ```
769
809
 
770
- ### `sendDom`
771
-
772
- ```js
773
- storiesOf('Components', module)
774
- .add(
775
- 'Some story ',
776
- () =>
777
- <div>Some Story</div>, {
778
- eyes: {
779
- sendDom: false
780
- }
781
- })
782
- ```
783
-
784
810
  ## Running Eyes-Storybook in Docker
785
811
 
786
812
  When running the SDK in docker, there might be issues related to properly launching the internal chrome browser via puppeteer. If you seem to have such issues, set `runInDocker: true` in your config file. This will pass the internal chrome browser special arguments, as described [here](https://github.com/GoogleChrome/puppeteer/blob/master/docs/troubleshooting.md#tips).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applitools/eyes-storybook",
3
- "version": "3.23.0",
3
+ "version": "3.25.1",
4
4
  "description": "",
5
5
  "engines": {
6
6
  "node": ">=8.6.0"
@@ -55,13 +55,13 @@
55
55
  "url": "git://github.com/applitools/eyes.sdk.javascript1.git"
56
56
  },
57
57
  "dependencies": {
58
- "@applitools/driver": "1.1.3",
59
- "@applitools/eyes-puppeteer": "1.8.2",
60
- "@applitools/eyes-sdk-core": "12.23.0",
58
+ "@applitools/driver": "1.2.6",
59
+ "@applitools/eyes-puppeteer": "1.8.4",
60
+ "@applitools/eyes-sdk-core": "12.23.18",
61
61
  "@applitools/functional-commons": "1.6.0",
62
62
  "@applitools/monitoring-commons": "1.0.19",
63
- "@applitools/test-server": "1.0.4",
64
- "@applitools/visual-grid-client": "15.8.21",
63
+ "@applitools/test-server": "1.0.5",
64
+ "@applitools/visual-grid-client": "15.8.37",
65
65
  "boxen": "4.2.0",
66
66
  "chalk": "3.0.0",
67
67
  "detect-port": "1.3.0",
@@ -74,10 +74,10 @@
74
74
  },
75
75
  "devDependencies": {
76
76
  "@applitools/scripts": "^1.0.1",
77
- "@applitools/sdk-release-kit": "0.13.0",
78
- "@applitools/sdk-shared": "0.9.5",
77
+ "@applitools/sdk-release-kit": "0.13.3",
78
+ "@applitools/sdk-shared": "0.9.6",
79
79
  "@applitools/snaptdout": "^1.0.1",
80
- "@applitools/utils": "1.2.2",
80
+ "@applitools/utils": "1.2.3",
81
81
  "@storybook/addon-options": "^5.2.8",
82
82
  "@storybook/react": "^5.2.8",
83
83
  "@testing-library/dom": "^5.6.1",
@@ -16,4 +16,5 @@ module.exports = {
16
16
  readStoriesTimeout: 60000,
17
17
  reloadPagePerStory: false,
18
18
  include: undefined,
19
+ startStorybookServerTimeout: 300,
19
20
  };
@@ -33,10 +33,6 @@ ${chalk.green(
33
33
 
34
34
  `;
35
35
 
36
- const startStorybookFailMsg = chalk.red(
37
- 'Could not find a storybook URL to test. This might be either because there was an error when starting the storybook dev server, or the parameter "storybookUrl" was not specified. Specify a URL with the "-u" parameter, or with "storybookUrl" in the config file (by default the config file is located at <project-folder>/applitools.config.js>).\n',
38
- );
39
-
40
36
  function refineErrorMessage({prefix, error}) {
41
37
  return `${prefix} ${error.message.replace('Evaluation failed: ', '')}`;
42
38
  }
@@ -45,6 +41,5 @@ module.exports = {
45
41
  missingApiKeyFailMsg,
46
42
  missingAppNameAndPackageJsonFailMsg,
47
43
  missingAppNameInPackageJsonFailMsg,
48
- startStorybookFailMsg,
49
44
  refineErrorMessage,
50
45
  };
@@ -6,7 +6,7 @@ function makeRenderStory({logger, testWindow, performance, timeItAsync}) {
6
6
  return function renderStory({config, story, snapshot, url}) {
7
7
  const {name, kind, parameters} = story;
8
8
  const title = getStoryTitle({name, kind, parameters});
9
- const eyesOptions = (parameters && parameters.eyes) || {};
9
+ const eyesOptions = Object.assign({}, config, (parameters && parameters.eyes) || {});
10
10
  const {
11
11
  ignoreDisplacements,
12
12
  ignoreRegions,
@@ -26,6 +26,9 @@ function makeRenderStory({logger, testWindow, performance, timeItAsync}) {
26
26
  ignore,
27
27
  accessibilityValidation,
28
28
  sendDom,
29
+ visualGridOptions,
30
+ useDom,
31
+ enablePatterns,
29
32
  } = eyesOptions;
30
33
 
31
34
  if (sizeMode) {
@@ -46,26 +49,20 @@ function makeRenderStory({logger, testWindow, performance, timeItAsync}) {
46
49
  properties: [
47
50
  {name: 'Component name', value: kind},
48
51
  {name: 'State', value: name},
49
- ...(properties !== undefined ? properties : config.properties || []),
52
+ ...(properties || []),
50
53
  ],
51
- ignoreDisplacements,
52
- accessibilitySettings:
53
- accessibilityValidation !== undefined
54
- ? accessibilityValidation
55
- : config.accessibilityValidation,
54
+ accessibilitySettings: accessibilityValidation,
56
55
  };
57
56
 
58
57
  const checkParams = {
59
58
  url,
60
59
  snapshot,
61
- ignore:
62
- ignoreRegionsBackCompat !== undefined ? ignoreRegionsBackCompat : config.ignoreRegions,
63
- floating: floatingRegions !== undefined ? floatingRegions : config.floatingRegions,
64
- layout: layoutRegions !== undefined ? layoutRegions : config.layoutRegions,
65
- strict: strictRegions !== undefined ? strictRegions : config.strictRegions,
66
- content: contentRegions !== undefined ? contentRegions : config.contentRegions,
67
- accessibility:
68
- accessibilityRegions !== undefined ? accessibilityRegions : config.accessibilityRegions,
60
+ ignore: ignoreRegionsBackCompat,
61
+ floating: floatingRegions,
62
+ layout: layoutRegions,
63
+ strict: strictRegions,
64
+ content: contentRegions,
65
+ accessibility: accessibilityRegions,
69
66
  scriptHooks,
70
67
  sizeMode,
71
68
  target,
@@ -73,7 +70,11 @@ function makeRenderStory({logger, testWindow, performance, timeItAsync}) {
73
70
  selector,
74
71
  region,
75
72
  tag,
76
- sendDom: sendDom !== undefined ? sendDom : config.sendDom,
73
+ sendDom,
74
+ visualGridOptions,
75
+ useDom,
76
+ enablePatterns,
77
+ ignoreDisplacements,
77
78
  };
78
79
 
79
80
  return timeItAsync(title, async () => {
@@ -2,7 +2,6 @@
2
2
  const {resolve} = require('path');
3
3
  const ora = require('ora');
4
4
  const StorybookConnector = require('./storybookConnector');
5
- const timeout = 5 * 60 * 1000; // 5 minutes
6
5
 
7
6
  async function startStorybookServer({
8
7
  packagePath,
@@ -12,6 +11,7 @@ async function startStorybookServer({
12
11
  storybookStaticDir,
13
12
  showStorybookOutput,
14
13
  logger,
14
+ startStorybookServerTimeout,
15
15
  }) {
16
16
  const isWindows = process.platform.startsWith('win');
17
17
  const storybookPath = resolve(packagePath, 'node_modules/.bin/start-storybook');
@@ -42,7 +42,13 @@ async function startStorybookServer({
42
42
 
43
43
  const spinner = ora('Starting storybook server');
44
44
  spinner.start();
45
- await storybookConnector.start(timeout);
45
+
46
+ try {
47
+ await storybookConnector.start(startStorybookServerTimeout * 1000);
48
+ } catch (error) {
49
+ spinner.fail(error);
50
+ process.exit(1);
51
+ }
46
52
  spinner.succeed('Storybook was started');
47
53
 
48
54
  return `http://${storybookHost}:${storybookPort}`;
@@ -86,11 +86,14 @@ class StorybookConnector extends EventEmitter {
86
86
  this.on('stderr', portBusyListener);
87
87
  this.on('stderr', successMessageListener);
88
88
 
89
- const minutes = timeout / 1000 / 60;
89
+ const minutes = Math.floor(timeout / 1000 / 60);
90
+ const seconds = (timeout / 1000) % 60;
90
91
  const timeoutID = setTimeout(
91
92
  reject,
92
93
  timeout,
93
- `Storybook didn't start after ${minutes} min waiting.`,
94
+ `Storybook dev server didn't start after waiting ${minutes ? `${minutes} minutes` : ''}${
95
+ minutes && seconds ? ' and ' : ''
96
+ }${seconds ? `${seconds} seconds` : ''}.`,
94
97
  );
95
98
  });
96
99
  }
@@ -115,8 +118,6 @@ class StorybookConnector extends EventEmitter {
115
118
  this._childProcess = spawn(this._storybookPath, args, {detached: false});
116
119
  this._addListeners();
117
120
 
118
- console.log(this._storybookPath);
119
-
120
121
  this._childProcess.once('exit', code => {
121
122
  if (!code) return;
122
123
  this._removeListeners();
@@ -41,6 +41,7 @@ async function validateAndPopulateConfig({config, packagePath, logger}) {
41
41
 
42
42
  config.storybookUrl = await startStorybookServer(Object.assign({packagePath, logger}, config));
43
43
 
44
+ // NOTE (Amit): I don't understand why this condition is here. It shouldn't happen. I might have been the one to put it here, but it seems like a mistake. We should take a thorough look and remove it.
44
45
  if (!config.storybookUrl) {
45
46
  console.log(startStorybookFailMsg);
46
47
  process.exit(1);