@applitools/eyes-storybook 3.25.1 → 3.25.2

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,16 @@
3
3
  ## Unreleased
4
4
 
5
5
 
6
+ ## 3.25.2 - 2021/10/30
7
+
8
+ - replace legacy logger construction with new
9
+ - deprecate `waitBeforeScreenshot` and introduce `waitBeforeCapture` instead
10
+ - updated to @applitools/driver@1.2.7 (from 1.2.6)
11
+ - updated to @applitools/eyes-puppeteer@1.8.5 (from 1.8.4)
12
+ - updated to @applitools/eyes-sdk-core@12.23.24 (from 12.23.18)
13
+ - updated to @applitools/test-server@1.0.6 (from 1.0.5)
14
+ - updated to @applitools/visual-grid-client@15.8.43 (from 15.8.37)
15
+
6
16
  ## 3.25.1 - 2021/10/20
7
17
 
8
18
  - updated to @applitools/eyes-puppeteer@1.8.4 (from 1.8.3)
package/README.md CHANGED
@@ -4,43 +4,51 @@ Applitools Eyes SDK for [Storybook](http://storybook.js.org).
4
4
 
5
5
  ### Table of contents
6
6
 
7
- - [Installation](#installation)
8
- * [Install npm package](#install-npm-package)
9
- * [Applitools API key](#applitools-api-key)
10
- - [Usage](#usage)
11
- * [Configuring local storybook server](#configuring-local-storybook-server)
12
- * [Standalone server](#standalone-server)
13
- * [Command line arguments](#command-line-arguments)
14
- - [Concurrency](#concurrency)
15
- - [Advanced configuration](#advanced-configuration)
16
- * [Method 1: Environment variables](#method-1--environment-variables)
17
- * [Method 2: The `applitools.config.js` file](#method-2--the--applitoolsconfigjs--file)
18
- - [Configuring the browser](#configuring-the-browser)
19
- * [Previous browser versions](#previous-browser-versions)
20
- * [Getting a screenshot of multiple browsers in parallel](#getting-a-screenshot-of-multiple-browsers-in-parallel)
21
- * [Device emulation](#device-emulation)
22
- * [Faking IE Browser](#faking-ie-browser)
23
- - [Per component configuration](#per-component-configuration)
24
- * [`include`](#include)
25
- * [`variations`](#variations)
26
- * [`waitBeforeScreenshot`](#waitbeforescreenshot)
27
- * [`properties`](#properties)
28
- * [`ignoreRegions`](#ignoreregions)
29
- * [`floatingRegions`](#floatingregions)
30
- * [`layoutRegions`](#layoutregions)
31
- * [`contentRegions`](#contentregions)
32
- * [`strictRegions`](#strictregions)
33
- * [`accessibilityRegions`](#accessibilityregions)
34
- * [`accessibilityValidation`](#accessibilityvalidation)
35
- * [Parameters that cannot be set as an Advanced configuration](#parameters-that-cannot-be-set-as-an-advanced-configuration)
36
- * [`runBefore`](#runbefore)
37
- * [`runAfter`](#runafter)
38
- * [`scriptHooks`](#scripthooks)
39
- + [beforeCaptureScreenshot](#beforecapturescreenshot)
40
- * [`layoutBreakpoints`](#layoutBreakpoints)
41
- - [Running Eyes-Storybook in Docker](#running-eyes-storybook-in-docker)
42
- - [Dealing with dynamic data](#dealing-with-dynamic-data)
43
- - [Troubleshooting](#troubleshooting)
7
+ - [Eyes-Storybook](#eyes-storybook)
8
+ - [Table of contents](#table-of-contents)
9
+ - [Installation](#installation)
10
+ - [Install npm package](#install-npm-package)
11
+ - [Applitools API key](#applitools-api-key)
12
+ - [Usage](#usage)
13
+ - [Configuring local storybook server](#configuring-local-storybook-server)
14
+ - [Standalone server](#standalone-server)
15
+ - [Command line arguments](#command-line-arguments)
16
+ - [Concurrency](#concurrency)
17
+ - [Advanced configuration](#advanced-configuration)
18
+ - [Method 1: Environment variables](#method-1-environment-variables)
19
+ - [Method 2: The `applitools.config.js` file](#method-2-the-applitoolsconfigjs-file)
20
+ - [Configuring the browser](#configuring-the-browser)
21
+ - [Previous browser versions](#previous-browser-versions)
22
+ - [Getting a screenshot of multiple browsers in parallel](#getting-a-screenshot-of-multiple-browsers-in-parallel)
23
+ - [Device emulation](#device-emulation)
24
+ - [iOS device](#ios-device)
25
+ - [Faking IE Browser](#faking-ie-browser)
26
+ - [Per component configuration](#per-component-configuration)
27
+ - [`include`](#include)
28
+ - [global](#global)
29
+ - [component](#component)
30
+ - [`variations`](#variations)
31
+ - [`waitBeforeCapture`](#waitbeforecapture)
32
+ - [`properties`](#properties)
33
+ - [`ignoreRegions`](#ignoreregions)
34
+ - [`floatingRegions`](#floatingregions)
35
+ - [`layoutRegions`](#layoutregions)
36
+ - [`contentRegions`](#contentregions)
37
+ - [`strictRegions`](#strictregions)
38
+ - [`accessibilityRegions`](#accessibilityregions)
39
+ - [`accessibilityValidation`](#accessibilityvalidation)
40
+ - [`ignoreDisplacements`](#ignoredisplacements)
41
+ - [`sendDom`](#senddom)
42
+ - [`visualGridOptions`](#visualgridoptions)
43
+ - [`scriptHooks`](#scripthooks)
44
+ - [beforeCaptureScreenshot](#beforecapturescreenshot)
45
+ - [Parameters that cannot be set as an advanced configuration](#parameters-that-cannot-be-set-as-an-advanced-configuration)
46
+ - [`runBefore` and `runAfter` functions](#runbefore-and-runafter-functions)
47
+ - [`runBefore`](#runbefore)
48
+ - [`runAfter`](#runafter)
49
+ - [`layoutBreakpoints`](#layoutbreakpoints)
50
+ - [Running Eyes-Storybook in Docker](#running-eyes-storybook-in-docker)
51
+ - [Dealing with dynamic data](#dealing-with-dynamic-data)
44
52
 
45
53
  ## Installation
46
54
 
@@ -169,7 +177,7 @@ In addition to command-line arguments, it's possible to define the following con
169
177
  | `jsonFilePath` | undefined | Directory path of a results file. If set, then a [JSON](https://www.json.org/json-en.html) file is created in this directory, the file is created with the name eyes.json and contains the Eyes test results. |
170
178
  | `tapFilePath` | undefined | Directory path of a results file. If set, then a [TAP](https://en.wikipedia.org/wiki/Test_Anything_Protocol#Specification) file is created in this directory, the file is created with the name eyes.tap and contains the Eyes test results. |
171
179
  | `xmlFilePath` | undefined | Directory path of a results file. If set, then a [XUnit XML](https://google.github.io/rich-test-results/xunitxml) file is created in this directory, the file is created with the name eyes.xml and contains the Eyes test results. |
172
- | `waitBeforeScreenshot` | undefined | Selector, function or timeout.<br/>If ```number``` then the argument is treated as time in milliseconds to wait before all screenshots.<br/>If ```string``` then the argument is treated as a selector for elements to wait for before all screenshots.<br/>If ```function```, then the argument is treated as a predicate to wait for before all screenshots.<br/><hr/>For per component configuration see [waitBeforeScreenshot.](#waitBeforeScreenshot)<br/>Note that we use Puppeteer's [page.waitForTimeout()](https://github.com/puppeteer/puppeteer/blob/main/docs/api.md#pagewaitfortimeoutmilliseconds), [page.waitForSelector()](https://github.com/puppeteer/puppeteer/blob/main/docs/api.md#pagewaitforselectorselector-options), [page.waitForXPath()](https://github.com/puppeteer/puppeteer/blob/main/docs/api.md#pagewaitforxpathxpath-options) and [page.waitForFunction()](https://github.com/puppeteer/puppeteer/blob/main/docs/api.md#pagewaitforfunctionpagefunction-options-args), checkout it's API for more details. |
180
+ | `waitBeforeCapture` | undefined | Selector, function or timeout.<br/>If ```number``` then the argument is treated as time in milliseconds to wait before all screenshots.<br/>If ```string``` then the argument is treated as a selector for elements to wait for before all screenshots.<br/>If ```function```, then the argument is treated as a predicate to wait for before all screenshots.<br/><hr/>For per component configuration see [waitBeforeCapture.](#waitBeforeCapture)<br/>Note that we use Puppeteer's [page.waitForTimeout()](https://github.com/puppeteer/puppeteer/blob/main/docs/api.md#pagewaitfortimeoutmilliseconds), [page.waitForSelector()](https://github.com/puppeteer/puppeteer/blob/main/docs/api.md#pagewaitforselectorselector-options), [page.waitForXPath()](https://github.com/puppeteer/puppeteer/blob/main/docs/api.md#pagewaitforxpathxpath-options) and [page.waitForFunction()](https://github.com/puppeteer/puppeteer/blob/main/docs/api.md#pagewaitforfunctionpagefunction-options-args), checkout it's API for more details. |
173
181
  | `include` | true | A predicate function, a string or a regular expression specifying which stories should be visually tested.<br/>Visual baselines will be created only for the components specified.<br/>The function receives an object with ```name```, ```kind```, ```storyTitle``` and ```parameters``` properties.<br/>For example (exclude all stories with a name that start with [SKIP]):<br/>```({name, kind, storyTitle, parameters}) => !/^\[SKIP\]/.test(name)```<br/>For more information, see [per component configuration - include](#include). |
174
182
  | `variations` | undefined | Specifies additional variations for all or some of the stories. For example, RTL. For more information, see [per component configuration - variations](#variations).|
175
183
  | `notifyOnCompletion` | false | If `true` batch completion notifications are sent. |
@@ -439,20 +447,20 @@ storiesOf('Components that support RTL', module)
439
447
  )
440
448
  ```
441
449
 
442
- ### `waitBeforeScreenshot`
450
+ ### `waitBeforeCapture`
443
451
 
444
452
  Selector or timeout, see [advanced configuration](#advanced-configuration) for more details.
445
453
 
446
454
  ```js
447
- storiesOf('Components with a waitBeforeScreenshot', module)
455
+ storiesOf('Components with a waitBeforeCapture', module)
448
456
  .add(
449
457
  'Some story',
450
458
  () => <span id="container" class="loading"></span>,
451
- {eyes: { waitBeforeScreenshot: '#container.ready' }}
459
+ {eyes: { waitBeforeCapture: '#container.ready' }}
452
460
  );
453
461
  ```
454
462
 
455
- _Note that the predicate option for `waitBeforeScreenshot` is currently not available in the per component configuration._
463
+ _Note that the predicate option for `waitBeforeCapture` is currently not available in the per component configuration._
456
464
 
457
465
  ### `properties`
458
466
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applitools/eyes-storybook",
3
- "version": "3.25.1",
3
+ "version": "3.25.2",
4
4
  "description": "",
5
5
  "engines": {
6
6
  "node": ">=8.6.0"
@@ -52,16 +52,18 @@
52
52
  "license": "SEE LICENSE IN LICENSE",
53
53
  "repository": {
54
54
  "type": "git",
55
- "url": "git://github.com/applitools/eyes.sdk.javascript1.git"
55
+ "url": "git://github.com/applitools/eyes.sdk.javascript1.git",
56
+ "directory": "packages/eyes-storybook"
56
57
  },
57
58
  "dependencies": {
58
- "@applitools/driver": "1.2.6",
59
- "@applitools/eyes-puppeteer": "1.8.4",
60
- "@applitools/eyes-sdk-core": "12.23.18",
59
+ "@applitools/driver": "1.2.7",
60
+ "@applitools/eyes-puppeteer": "1.8.5",
61
+ "@applitools/eyes-sdk-core": "12.23.24",
61
62
  "@applitools/functional-commons": "1.6.0",
63
+ "@applitools/logger": "1.0.5",
62
64
  "@applitools/monitoring-commons": "1.0.19",
63
- "@applitools/test-server": "1.0.5",
64
- "@applitools/visual-grid-client": "15.8.37",
65
+ "@applitools/test-server": "1.0.6",
66
+ "@applitools/visual-grid-client": "15.8.43",
65
67
  "boxen": "4.2.0",
66
68
  "chalk": "3.0.0",
67
69
  "detect-port": "1.3.0",
@@ -74,10 +76,10 @@
74
76
  },
75
77
  "devDependencies": {
76
78
  "@applitools/scripts": "^1.0.1",
77
- "@applitools/sdk-release-kit": "0.13.3",
78
- "@applitools/sdk-shared": "0.9.6",
79
+ "@applitools/sdk-release-kit": "0.13.4",
80
+ "@applitools/sdk-shared": "0.9.7",
79
81
  "@applitools/snaptdout": "^1.0.1",
80
- "@applitools/utils": "1.2.3",
82
+ "@applitools/utils": "1.2.4",
81
83
  "@storybook/addon-options": "^5.2.8",
82
84
  "@storybook/react": "^5.2.8",
83
85
  "@testing-library/dom": "^5.6.1",
package/src/cli.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
  const yargs = require('yargs');
3
- const {Logger} = require('@applitools/eyes-sdk-core');
3
+ const {makeLogger} = require('@applitools/logger');
4
4
  const {configParams: externalConfigParams} = require('@applitools/visual-grid-client');
5
5
  const VERSION = require('../package.json').version;
6
6
  const eyesStorybook = require('./eyesStorybook');
@@ -32,8 +32,7 @@ const {performance, timeItAsync} = makeTiming();
32
32
  console.log(`Using @applitools/eyes-storybook version ${VERSION}.\n`);
33
33
 
34
34
  const config = generateConfig({argv, defaultConfig, externalConfigParams});
35
- const logger = new Logger(config.showLogs, 'eyes');
36
- logger.setIncludeTime(true);
35
+ const logger = makeLogger({level: config.showLogs ? 'info' : 'silent', label: 'eyes'});
37
36
  await validateAndPopulateConfig({config, logger, packagePath: process.cwd()});
38
37
  logger.log(`Running with the following config:\n${configDigest(config)}`);
39
38
  const [err, results] = await presult(
@@ -7,8 +7,9 @@ module.exports = {
7
7
  storybookUrl: undefined,
8
8
  storybookStaticDir: undefined,
9
9
  showStorybookOutput: false,
10
- waitBeforeScreenshot: 50,
10
+ waitBeforeScreenshot: 50, // backward compatibility
11
11
  waitBeforeScreenshots: 50, // backward compatibility
12
+ waitBeforeCapture: 50,
12
13
  viewportSize: {width: 1024, height: 768},
13
14
  tapFilePath: undefined,
14
15
  xmlFilePath: undefined,
@@ -37,7 +37,7 @@ async function eyesStorybook({
37
37
  let transitioning = false;
38
38
  takeMemLoop();
39
39
  logger.log('eyesStorybook started');
40
- const {storybookUrl, waitBeforeScreenshot, readStoriesTimeout, reloadPagePerStory} = config;
40
+ const {storybookUrl, waitBeforeCapture, readStoriesTimeout, reloadPagePerStory} = config;
41
41
 
42
42
  let iframeUrl;
43
43
  try {
@@ -76,8 +76,8 @@ async function eyesStorybook({
76
76
  });
77
77
  const pagePool = createPagePool({initPage, logger});
78
78
 
79
- const doTakeDomSnapshots = async ({page, layoutBreakpoints}) => {
80
- const driver = new Driver({spec, driver: page, logger: logger._getNewLogger()});
79
+ const doTakeDomSnapshots = async ({page, layoutBreakpoints, waitBeforeCapture}) => {
80
+ const driver = new Driver({spec, driver: page, logger});
81
81
  const skipResources = getResourceUrlsInCache();
82
82
  const result = await takeDomSnapshots({
83
83
  logger,
@@ -90,6 +90,7 @@ async function eyesStorybook({
90
90
  getViewportSize: () => config.viewportSize,
91
91
  getIosDevicesSizes,
92
92
  getEmulatedDevicesSizes,
93
+ waitBeforeCapture,
93
94
  });
94
95
  return result;
95
96
  };
@@ -120,7 +121,7 @@ async function eyesStorybook({
120
121
  const getStoryData = makeGetStoryData({
121
122
  logger,
122
123
  takeDomSnapshots: doTakeDomSnapshots,
123
- waitBeforeScreenshot,
124
+ waitBeforeCapture,
124
125
  });
125
126
 
126
127
  const renderStory = makeRenderStory({
@@ -14,24 +14,29 @@ function generateConfig({argv = {}, defaultConfig = {}, externalConfigParams = [
14
14
  const result = Object.assign({}, defaultConfig, config, argvConfig);
15
15
 
16
16
  // backward compatibility
17
- if (
18
- result.waitBeforeScreenshots !== defaultConfig.waitBeforeScreenshots &&
19
- result.waitBeforeScreenshot === defaultConfig.waitBeforeScreenshot
20
- ) {
21
- console.log(
22
- deprecationWarning({
23
- deprecatedThing: "'waitBeforeScreenshots'",
24
- newThing: "'waitBeforeScreenshot' (no 's')",
25
- }),
26
- );
27
- result.waitBeforeScreenshot = result.waitBeforeScreenshots;
17
+ if (result.waitBeforeCapture === defaultConfig.waitBeforeCapture) {
18
+ if (result.waitBeforeScreenshots !== defaultConfig.waitBeforeScreenshots) {
19
+ console.log(
20
+ deprecationWarning({
21
+ deprecatedThing: "'waitBeforeScreenshots'",
22
+ newThing: "'waitBeforeCapture'",
23
+ }),
24
+ );
25
+ result.waitBeforeCapture = result.waitBeforeScreenshots;
26
+ }
27
+ if (result.waitBeforeScreenshot !== defaultConfig.waitBeforeScreenshot) {
28
+ console.log(
29
+ deprecationWarning({
30
+ deprecatedThing: "'waitBeforeScreenshot'",
31
+ newThing: "'waitBeforeCapture'",
32
+ }),
33
+ );
34
+ result.waitBeforeCapture = result.waitBeforeScreenshot;
35
+ }
28
36
  }
29
37
 
30
- if (
31
- typeof result.waitBeforeScreenshot === 'string' &&
32
- !isNaN(parseInt(result.waitBeforeScreenshot))
33
- ) {
34
- result.waitBeforeScreenshot = Number(result.waitBeforeScreenshot);
38
+ if (typeof result.waitBeforeCapture === 'string' && !isNaN(parseInt(result.waitBeforeCapture))) {
39
+ result.waitBeforeCapture = Number(result.waitBeforeCapture);
35
40
  }
36
41
 
37
42
  if (result.showLogs === '1') {
@@ -8,7 +8,7 @@ const {URL} = require('url');
8
8
  const runRunAfterScript = require('../dist/runRunAfterScript');
9
9
  const waitFor = require('./waitFor');
10
10
 
11
- function makeGetStoryData({logger, takeDomSnapshots, waitBeforeScreenshot, reloadPagePerStory}) {
11
+ function makeGetStoryData({logger, takeDomSnapshots, waitBeforeCapture, reloadPagePerStory}) {
12
12
  return async function getStoryData({story, storyUrl, page, waitBeforeStory}) {
13
13
  const title = getStoryTitle(story);
14
14
  logger.log(`getting data from story`, title);
@@ -32,9 +32,9 @@ function makeGetStoryData({logger, takeDomSnapshots, waitBeforeScreenshot, reloa
32
32
  await renderStoryLegacy();
33
33
  }
34
34
 
35
- const wait = waitBeforeStory || waitBeforeScreenshot;
35
+ const wait = waitBeforeStory || waitBeforeCapture;
36
36
  if (typeof wait === 'number') {
37
- ArgumentGuard.greaterThanOrEqualToZero(wait, 'waitBeforeScreenshot', true);
37
+ ArgumentGuard.greaterThanOrEqualToZero(wait, 'waitBeforeCapture', true);
38
38
  }
39
39
  if (wait) {
40
40
  logger.log(`waiting before screenshot of ${title} ${wait}`);
@@ -52,6 +52,12 @@ function makeGetStoryData({logger, takeDomSnapshots, waitBeforeScreenshot, reloa
52
52
  const snapshots = await takeDomSnapshots({
53
53
  page,
54
54
  layoutBreakpoints: eyesParameters ? eyesParameters.layoutBreakpoints : undefined,
55
+ waitBeforeCapture: wait
56
+ ? async () => {
57
+ logger.log(`waiting before screenshot of ${title} ${wait}`);
58
+ await waitFor(page, wait);
59
+ }
60
+ : undefined,
55
61
  });
56
62
 
57
63
  if (eyesParameters && eyesParameters.runAfter) {
@@ -62,7 +62,7 @@ function makeRenderStories({
62
62
  const story = stories[currIndex++];
63
63
  const storyUrl = getStoryUrl(story, storybookUrl);
64
64
  const title = getStoryTitle(story);
65
- const {waitBeforeScreenshot} = (story.parameters && story.parameters.eyes) || {};
65
+ const {waitBeforeCapture} = (story.parameters && story.parameters.eyes) || {};
66
66
 
67
67
  try {
68
68
  let [error, storyData] = await presult(
@@ -70,7 +70,7 @@ function makeRenderStories({
70
70
  story,
71
71
  storyUrl,
72
72
  page,
73
- waitBeforeStory: waitBeforeScreenshot,
73
+ waitBeforeStory: waitBeforeCapture,
74
74
  }),
75
75
  );
76
76
 
@@ -90,7 +90,7 @@ function makeRenderStories({
90
90
  story,
91
91
  storyUrl,
92
92
  page: newPageObj.page,
93
- waitBeforeStory: waitBeforeScreenshot,
93
+ waitBeforeStory: waitBeforeCapture,
94
94
  }),
95
95
  );
96
96
  error = newError;