@applitools/eyes-cypress 3.27.1 → 3.27.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
@@ -10,6 +10,25 @@
10
10
 
11
11
 
12
12
 
13
+ ## 3.27.3 - 2022/10/19
14
+
15
+ ### Features
16
+ - Changed default value of `sendDom` from `true` to dynamically calculated
17
+ ### Bug fixes
18
+ - Fix chrome emulation environment structure
19
+ - Fixed issue with ufg renders failing intermittently
20
+ - Fixed issue with universal process spawning is failing due to a timeout
21
+
22
+ ## 3.27.2 - 2022/10/9
23
+
24
+ ### Features
25
+ - Don't fail `eyes.open` when there is a failure to set viewport size in `UFG`.
26
+ - Using `lazyLoad.waitingTime` as a delay between stitches by default
27
+ - Deprecated "Content" match level value in favor of "IgnoreColors"
28
+ ### Bug fixes
29
+ - Internal Infrastructure update
30
+ - Fixed bug when error was thrown when coded region wasn't found using selector
31
+
13
32
  ## 3.27.1 - 2022/8/1
14
33
 
15
34
  ### Features
package/README.md CHANGED
@@ -662,7 +662,7 @@ cy.get('.region.two:nth-child(2)').then(el => {
662
662
  cy.eyesCheckWindow({
663
663
  fully: false,
664
664
  ignore: [
665
- {type: 'css', selector: '.region.three:nth-child(3n)'},
665
+ {region: {type: 'css', selector: '.region.three:nth-child(3n)'}, regionId: 'region3'},
666
666
  {type: 'xpath', selector: '//div[@class="region one"][3]'},
667
667
  {element: el, regionId: 'my-region-id'},
668
668
  ],
@@ -716,7 +716,7 @@ after(() => {
716
716
 
717
717
  ```js
718
718
  after(() => {
719
- cy.eyesGetAllTestResults().then(summary => {
719
+ cy.eyesGetAllTestResults().then(async summary => {
720
720
  for(const result of summary.getAllResults()) {
721
721
  await result.getTestResults().delete()
722
722
  }
package/bin/eyes-setup.js CHANGED
@@ -2,38 +2,30 @@
2
2
  'use strict';
3
3
 
4
4
  const chalk = require('chalk');
5
- const {handlePlugin} = require('../src/setup/handlePlugin');
6
- const {handleCommands, handlerCommandsCypress10} = require('../src/setup/handleCommands');
7
- const {handleTypeScript, handlerTypeScriptCypress10} = require('../src/setup/handleTypeScript');
8
- const {version} = require('../package');
9
- const fs = require('fs');
5
+ const handlePlugin = require('../src/setup/handlePlugin');
6
+ const handleCommands = require('../src/setup/handleCommands');
7
+ const {handleTypeScript} = require('../src/setup/handleTypeScript');
8
+ const getCypressVersion = require('../src/setup/getCypressVersion');
9
+ const getCypressPaths = require('../src/setup/getCypressPaths');
10
+
10
11
  const cwd = process.cwd();
11
12
  const semver = require('semver');
13
+ const {version} = require('../package');
12
14
 
13
- console.log(chalk.cyan('Setup eyes-cypress', version));
14
- const packageJson = JSON.parse(fs.readFileSync('package.json'));
15
- let cypressVersion;
15
+ console.log(chalk.cyan('Setup Eyes-Cypress', version));
16
16
 
17
- if (packageJson.dependencies && packageJson.dependencies.cypress) {
18
- cypressVersion = packageJson.dependencies.cypress;
19
- } else if (packageJson.devDependencies && packageJson.devDependencies.cypress) {
20
- cypressVersion = packageJson.devDependencies.cypress;
21
- }
22
- const logStr = `Cypress version that was found ${cypressVersion}`;
17
+ const cypressVersion = getCypressVersion();
18
+ console.log(chalk.cyan(`Cypress version: ${cypressVersion}`));
19
+
20
+ const isCypress10 = semver.satisfies(cypressVersion, '>=10.0.0');
23
21
  try {
24
- if (semver.satisfies(semver.coerce(String(cypressVersion)), '>=10.0.0')) {
25
- console.log(chalk.cyan(logStr, ' (above v10 handler)'));
26
- handlePlugin(cwd, true);
27
- const supportFilePath = handlerCommandsCypress10(cwd);
28
- handlerTypeScriptCypress10(supportFilePath);
29
- } else {
30
- console.log(chalk.cyan(logStr));
31
- handlePlugin(cwd, false);
32
- handleCommands(cwd);
33
- handleTypeScript(cwd);
34
- }
35
- } catch (e) {
36
- console.log(chalk.red('Setup error:\n', e));
22
+ const {plugin, support, typescript} = getCypressPaths({cwd, isCypress10});
23
+ handlePlugin(plugin);
24
+ handleCommands(support);
25
+ handleTypeScript(typescript);
26
+ } catch (err) {
27
+ console.log(chalk.red(`Setup error:\n${err.message}`));
28
+ process.exit(1);
37
29
  }
38
30
 
39
31
  console.log(chalk.cyan('Setup done!'));
@@ -42,8 +42,8 @@ function getViewportSize() {
42
42
  //@ts-ignore
43
43
  const currWindow = cy.state('window');
44
44
  const viewportSize = {
45
- width: Math.max(currWindow.document.documentElement.clientWidth || 0, currWindow.innerWidth || 0),
46
- height: Math.max(currWindow.document.documentElement.clientHeight || 0, currWindow.innerHeight || 0)
45
+ width: currWindow.innerWidth || currWindow.document.documentElement.clientWidth || currWindow.document.body.clientWidth,
46
+ height: currWindow.innerHeight || currWindow.document.documentElement.clientHeight || currWindow.document.body.clientHeight
47
47
  };
48
48
  return viewportSize;
49
49
  }
package/index.d.ts CHANGED
@@ -1,6 +1,4 @@
1
1
  /// <reference types="cypress" />
2
-
3
- import type * as types from '@applitools/types'
4
2
  import type * as api from '@applitools/eyes-api'
5
3
 
6
4
  type MaybeArray<T> = T | T[]
@@ -9,7 +7,7 @@ type LegacyRegion = {left: number; top: number; width: number; height: number}
9
7
  type Selector = {selector: string; type?: 'css' | 'xpath', nodeType?: 'element' | 'shadow-root'} | 'string'
10
8
  type Element = HTMLElement | JQuery<HTMLElement>
11
9
 
12
- interface CypressCheckSettings extends types.CheckSettings<Element, Selector> {
10
+ interface CypressCheckSettings extends api.CheckSettingsPlain<Element, Selector>{
13
11
  tag?: CypressCheckSettings['name']
14
12
 
15
13
  target?: 'window' | 'region'
@@ -21,13 +19,14 @@ interface CypressCheckSettings extends types.CheckSettings<Element, Selector> {
21
19
  content?: MaybeArray<CypressCheckSettings['contentRegions'][number] | LegacyRegion>
22
20
  strict?: MaybeArray<CypressCheckSettings['strictRegions'][number] | LegacyRegion>
23
21
  floating?: MaybeArray<CypressCheckSettings['floatingRegions'][number] | (({element: Element} | Selector | LegacyRegion) & {maxUpOffset?: number; maxDownOffset?: number; maxLeftOffset?: number; maxRightOffset?: number})>
24
- accessibility?: MaybeArray<CypressCheckSettings['accessibilityRegions'][number] | (({element: Element} | Selector | LegacyRegion) & {accessibilityType?: types.AccessibilityRegionType})>
25
-
22
+ accessibility?: MaybeArray<CypressCheckSettings['accessibilityRegions'][number] | (({element: Element} | Selector | LegacyRegion) & {accessibilityType?: api.AccessibilityRegionTypePlain})>
26
23
  scriptHooks?: CypressCheckSettings['hooks']
24
+ ignoreCaret?: boolean
25
+ ignoreDisplacements?: boolean
27
26
  }
28
27
 
29
- interface CypressEyesConfig extends types.EyesConfig<Element, Selector> {
30
- browser?: MaybeArray<CypressEyesConfig['browsersInfo'][number] | {deviceName: string; screenOrientation?: types.ScreenOrientation; name?: string}>
28
+ interface CypressEyesConfig extends api.ConfigurationPlain<Element, Selector> {
29
+ browser?: MaybeArray<CypressEyesConfig['browsersInfo'][number] | {deviceName: string; screenOrientation?: api.ScreenOrientationPlain; name?: string}>
31
30
 
32
31
  batchId?: CypressEyesConfig['batch']['id']
33
32
  batchName?: CypressEyesConfig['batch']['name']
@@ -36,10 +35,7 @@ interface CypressEyesConfig extends types.EyesConfig<Element, Selector> {
36
35
 
37
36
  envName?: CypressEyesConfig['environmentName']
38
37
 
39
- ignoreCaret?: CypressEyesConfig['defaultMatchSettings']['ignoreCaret']
40
- matchLevel?: CypressEyesConfig['defaultMatchSettings']['matchLevel']
41
38
  accessibilitySettings?: CypressEyesConfig['defaultMatchSettings']['accessibilitySettings']
42
- ignoreDisplacements?: CypressEyesConfig['defaultMatchSettings']['ignoreDisplacements']
43
39
  }
44
40
 
45
41
  declare global {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applitools/eyes-cypress",
3
- "version": "3.27.1",
3
+ "version": "3.27.3",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git://github.com/applitools/eyes.sdk.javascript1.git",
@@ -35,7 +35,7 @@
35
35
  "test:ts": "yarn test:ts:compile && yarn test:ts:run",
36
36
  "test:ts:compile": "tsc --project test/e2e/ts/cypress",
37
37
  "test:ts:run": "cypress run --config-file test/e2e/ts/cypress-ts.json",
38
- "test:coverage": "yarn generate:tests && cd test/coverage/generic && yarn && unset APPLITOOLS_API_KEY && APPLITOOLS_BATCH_NAME='JS Coverage Tests: eyes-selenium' APPLITOOLS_BATCH_ID=$(uuidgen) npx cypress run",
38
+ "test:coverage": "yarn generate:tests && cd test/coverage/generic && yarn && unset APPLITOOLS_API_KEY && APPLITOOLS_BATCH_NAME='JS Coverage Tests: eyes-cypress' APPLITOOLS_BATCH_ID=$(uuidgen) npx cypress run",
39
39
  "test:e2e": "mkdir -p test/fixtures/testAppCopies && mocha --no-timeouts 'test/e2e/**/*.test.js'",
40
40
  "cypress": "cypress open --config-file test/fixtures/cypress-play.json",
41
41
  "cypress:new": "cd test/play && yarn && npx cypress open",
@@ -45,7 +45,7 @@
45
45
  "render": "run(){ npx cypress run --config integrationFolder=test/fixtures/testApp/cypress/render,pluginsFile=test/fixtures/testApp/cypress/plugins/index-render.js,supportFile=test/fixtures/testApp/cypress/support/index-run.js --env url=$1; }; run",
46
46
  "prepublish:setup": "sudo apt-get install xvfb",
47
47
  "deps": "bongo deps",
48
- "preversion": "yarn build && bongo preversion --skip-deps --verifyPendingChanges",
48
+ "preversion": "yarn build && bongo preversion --skip-deps --verifyPendingChanges --skipVerifyInstalledVersions",
49
49
  "version": "bongo version --withPendingChanges",
50
50
  "postversion": "bongo postversion --skip-release-notification"
51
51
  },
@@ -55,24 +55,24 @@
55
55
  }
56
56
  },
57
57
  "dependencies": {
58
- "@applitools/eyes-api": "1.7.5",
59
- "@applitools/eyes-universal": "2.10.3",
58
+ "@applitools/core": "1.2.0",
59
+ "@applitools/eyes-api": "1.9.0",
60
+ "@applitools/eyes-universal": "2.16.5",
60
61
  "@applitools/functional-commons": "1.6.0",
61
- "@applitools/logger": "1.1.15",
62
- "@applitools/visual-grid-client": "15.13.13",
62
+ "@applitools/logger": "1.1.27",
63
63
  "chalk": "3.0.0",
64
+ "semver": "7.3.7",
64
65
  "uuid": "8.3.2",
65
66
  "ws": "8.5.0"
66
67
  },
67
68
  "devDependencies": {
68
- "@applitools/bongo": "^2.1.6",
69
- "@applitools/scripts": "1.1.0",
69
+ "@applitools/bongo": "^2.2.0",
70
+ "@applitools/scripts": "1.2.0",
70
71
  "@applitools/sdk-coverage-tests": "^2.3.20",
71
72
  "@applitools/snaptdout": "1.0.1",
72
- "@applitools/test-server": "1.1.4",
73
- "@applitools/test-utils": "1.4.3",
74
- "@applitools/types": "^1.5.8",
75
- "@applitools/utils": "1.3.10",
73
+ "@applitools/test-server": "1.1.6",
74
+ "@applitools/test-utils": "1.5.2",
75
+ "@applitools/utils": "1.3.13",
76
76
  "@types/node": "12",
77
77
  "@types/ws": "^8.2.2",
78
78
  "@typescript-eslint/eslint-plugin": "^5.10.2",
@@ -80,7 +80,7 @@
80
80
  "chai": "4.2.0",
81
81
  "chai-spies": "1.0.0",
82
82
  "cookie-parser": "1.4.4",
83
- "cypress": "8.0.0",
83
+ "cypress": "9.7.0",
84
84
  "eslint": "8.10.0",
85
85
  "eslint-plugin-mocha-no-only": "1.1.0",
86
86
  "eslint-plugin-node": "7.0.1",
@@ -92,8 +92,7 @@
92
92
  "ncp": "2.0.0",
93
93
  "node-fetch": "2.6.0",
94
94
  "prettier": "1.19.1",
95
- "semver": "^7.3.7",
96
- "typescript": "4.6.4"
95
+ "typescript": "4.8.4"
97
96
  },
98
97
  "engines": {
99
98
  "node": ">=12.13.0"
@@ -38,7 +38,7 @@ Cypress.Commands.add('eyesGetAllTestResults', () => {
38
38
  await Promise.all(closePromiseArr);
39
39
  const summary = await socket.request('EyesManager.closeManager', {manager, throwErr});
40
40
 
41
- const deleteTest = ({testId, batchId, secretToken}) => {
41
+ const deleteTest = ({settings: {testId, batchId, secretToken}}) => {
42
42
  const {serverUrl, proxy, apiKey} = Cypress.config('appliConfFile');
43
43
  return socket.request('Core.deleteTest', {
44
44
  settings: {
@@ -51,7 +51,9 @@ Cypress.Commands.add('eyesGetAllTestResults', () => {
51
51
  },
52
52
  });
53
53
  };
54
-
54
+ summary.results = summary.results.map(res => {
55
+ return {...res, result: res.testResults, error: res.exception, renderer: res.browserInfo};
56
+ });
55
57
  return new TestResultsSummary({summary, deleteTest});
56
58
  });
57
59
  });
@@ -36,14 +36,29 @@ function eyesCheckMapValues({args, refer}) {
36
36
  if (config.element) {
37
37
  if (isHTMLElement(config.element)) {
38
38
  regionSettings = {
39
- region: refer.ref(config.element),
39
+ region: Object.assign(refer.ref(config.element), {type: 'element'}),
40
40
  };
41
41
  } else {
42
42
  // JQuery element
43
43
  regionSettings = {
44
- region: refer.ref(config.element[0]),
44
+ region: Object.assign(refer.ref(config.element[0]), {type: 'element'}),
45
45
  };
46
46
  }
47
+ } else if (
48
+ config.region &&
49
+ config.region.hasOwnProperty('top') &&
50
+ config.region.hasOwnProperty('left') &&
51
+ config.region.hasOwnProperty('width') &&
52
+ config.region.hasOwnProperty('height')
53
+ ) {
54
+ regionSettings = {
55
+ region: {
56
+ y: config.region.top,
57
+ x: config.region.left,
58
+ width: config.region.width,
59
+ height: config.region.height,
60
+ },
61
+ };
47
62
  } else if (!config.hasOwnProperty('selector')) {
48
63
  regionSettings = {
49
64
  region: config.region,
@@ -128,8 +143,8 @@ function eyesCheckMapValues({args, refer}) {
128
143
  }
129
144
  } else {
130
145
  accessabilityRegion.region = {
131
- top: region.top,
132
- left: region.left,
146
+ y: region.top,
147
+ x: region.left,
133
148
  width: region.width,
134
149
  height: region.height,
135
150
  };
@@ -161,8 +176,8 @@ function eyesCheckMapValues({args, refer}) {
161
176
  }
162
177
  } else {
163
178
  floatingRegion.region = {
164
- top: region.top,
165
- left: region.left,
179
+ y: region.top,
180
+ x: region.left,
166
181
  width: region.width,
167
182
  height: region.height,
168
183
  };
@@ -178,11 +193,13 @@ function eyesCheckMapValues({args, refer}) {
178
193
  const elements = [];
179
194
  for (const region of regions) {
180
195
  if (isHTMLElement(region)) {
181
- elements.push(refer.ref(region));
196
+ elements.push(Object.assign(refer.ref(region), {type: 'element'}));
182
197
  } else if (region.jquery) {
183
198
  region.each(function() {
184
199
  // there's a small chance that `this` is not an HTML element. So we just verify it.
185
- elements.push(isHTMLElement(this) ? refer.ref(this) : this);
200
+ elements.push(
201
+ isHTMLElement(this) ? Object.assign(refer.ref(this), {type: 'element'}) : this,
202
+ );
186
203
  });
187
204
  } else {
188
205
  elements.push(region);
@@ -47,10 +47,11 @@ function eyesOpenMapValues({args, appliConfFile, testName, shouldUseBrowserHooks
47
47
 
48
48
  if (browsersInfo) {
49
49
  if (Array.isArray(browsersInfo)) {
50
- browsersInfo.forEach(fillDefaultBrowserName);
50
+ for (const [index, value] of browsersInfo.entries()) {
51
+ browsersInfo[index] = fillDefaultBrowserName(value);
52
+ }
51
53
  } else {
52
- fillDefaultBrowserName(browsersInfo);
53
- browsersInfo = [browsersInfo];
54
+ browsersInfo = [fillDefaultBrowserName(browsersInfo)];
54
55
  }
55
56
  }
56
57
 
@@ -90,6 +91,12 @@ function eyesOpenMapValues({args, appliConfFile, testName, shouldUseBrowserHooks
90
91
  function fillDefaultBrowserName(browser) {
91
92
  if (!browser.name && !browser.iosDeviceInfo && !browser.chromeEmulationInfo) {
92
93
  browser.name = 'chrome';
94
+ if (browser.deviceName) {
95
+ browser = {chromeEmulationInfo: browser};
96
+ }
97
+ return browser;
98
+ } else {
99
+ return browser;
93
100
  }
94
101
  }
95
102
 
@@ -14,16 +14,19 @@ class Refer {
14
14
  }
15
15
 
16
16
  check(value) {
17
- return (
18
- value &&
19
- (value.nodeType === Node.ELEMENT_NODE ||
20
- value.nodeType === Node.DOCUMENT_NODE ||
21
- value.ownerDocument ||
22
- (value.constructor && value.constructor.name === 'Window'))
23
- );
17
+ if (!value) return;
18
+ if (value.nodeType === Node.ELEMENT_NODE) {
19
+ return 'element';
20
+ } else if (value.nodeType === Node.DOCUMENT_NODE || value.ownerDocument) {
21
+ return 'context';
22
+ } else if (value.constructor && value.constructor.name === 'Window') {
23
+ return 'driver';
24
+ }
24
25
  }
26
+
25
27
  ref(value, parentRef) {
26
- if (this.check(value)) {
28
+ const refType = this.check(value);
29
+ if (refType) {
27
30
  const ref = uuid.v4();
28
31
  this.store.set(ref, value);
29
32
  if (parentRef) {
@@ -34,7 +37,7 @@ class Refer {
34
37
  }
35
38
  childRefs.add({[REF_ID]: ref});
36
39
  }
37
- return {[REF_ID]: ref};
40
+ return {[REF_ID]: ref, type: refType};
38
41
  } else if (Array.isArray(value)) {
39
42
  return value.map(value => this.ref(value, parentRef));
40
43
  } else if (typeof value === 'object' && value !== null) {
@@ -1,12 +1,14 @@
1
+ /* global Node */
1
2
  const spec = require('../../dist/browser/spec-driver');
2
3
 
3
4
  function socketCommands(socket, refer) {
4
5
  socket.command('Driver.executeScript', ({context, script, arg = []}) => {
5
6
  const res = spec.executeScript(refer.deref(context), script, derefArgs(arg));
6
- return refer.ref(res);
7
+ return res ? refer.ref(res) : res;
7
8
  });
9
+
8
10
  socket.command('Driver.mainContext', () => {
9
- return refer.ref(spec.mainContext());
11
+ return refer.ref(spec.mainContext()), {type: 'context'};
10
12
  });
11
13
 
12
14
  socket.command('Driver.parentContext', ({context}) => {
@@ -42,12 +44,12 @@ function socketCommands(socket, refer) {
42
44
  );
43
45
  });
44
46
 
45
- socket.command('Driver.getUrl', context => {
46
- return spec.getUrl(refer.deref(context));
47
+ socket.command('Driver.getUrl', ({driver}) => {
48
+ return spec.getUrl(refer.deref(driver));
47
49
  });
48
50
 
49
- socket.command('Driver.getTitle', context => {
50
- return spec.getTitle(refer.deref(context.driver));
51
+ socket.command('Driver.getTitle', ({driver}) => {
52
+ return spec.getTitle(refer.deref(driver));
51
53
  });
52
54
 
53
55
  socket.command('Driver.getCookies', async () => {
@@ -47,8 +47,8 @@ export function getViewportSize(): Object {
47
47
  //@ts-ignore
48
48
  const currWindow = cy.state('window')
49
49
  const viewportSize = {
50
- width: Math.max(currWindow.document.documentElement.clientWidth || 0, currWindow.innerWidth || 0),
51
- height: Math.max(currWindow.document.documentElement.clientHeight || 0, currWindow.innerHeight || 0)
50
+ width: currWindow.innerWidth || currWindow.document.documentElement.clientWidth || currWindow.document.body.clientWidth,
51
+ height: currWindow.innerHeight || currWindow.document.documentElement.clientHeight || currWindow.document.body.clientHeight
52
52
  };
53
53
  return viewportSize;
54
54
  }
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
  const utils = require('@applitools/utils');
3
- const {configParams, TypeUtils} = require('@applitools/visual-grid-client');
3
+ const {configParams} = require('./configParams');
4
4
  const DEFAULT_TEST_CONCURRENCY = 5;
5
5
  const uuid = require('uuid');
6
6
 
@@ -24,11 +24,11 @@ function makeConfig() {
24
24
  config.failCypressOnDiff = false;
25
25
  }
26
26
 
27
- if (TypeUtils.isString(config.showLogs)) {
27
+ if (utils.types.isString(config.showLogs)) {
28
28
  config.showLogs = config.showLogs === 'true' || config.showLogs === '1';
29
29
  }
30
30
 
31
- if (TypeUtils.isString(config.testConcurrency)) {
31
+ if (utils.types.isString(config.testConcurrency)) {
32
32
  config.testConcurrency = Number(config.testConcurrency);
33
33
  }
34
34
 
@@ -0,0 +1,48 @@
1
+ 'use strict';
2
+
3
+ const configParams = [
4
+ 'appName',
5
+ 'testName',
6
+ 'displayName',
7
+ 'browser',
8
+ 'url',
9
+ 'apiKey',
10
+ 'showLogs',
11
+ 'batch',
12
+ 'batchId',
13
+ 'batchName',
14
+ 'batchSequenceName',
15
+ 'batchSequence',
16
+ 'properties',
17
+ 'baselineBranchName',
18
+ 'baselineBranch',
19
+ 'baselineEnvName',
20
+ 'baselineName',
21
+ 'envName',
22
+ 'ignoreCaret',
23
+ 'isDisabled',
24
+ 'matchLevel',
25
+ 'parentBranchName',
26
+ 'parentBranch',
27
+ 'branchName',
28
+ 'branch',
29
+ 'proxy',
30
+ 'autProxy',
31
+ 'saveDiffs',
32
+ 'saveFailedTests',
33
+ 'saveNewTests',
34
+ 'compareWithParentBranch',
35
+ 'ignoreBaseline',
36
+ 'serverUrl',
37
+ 'concurrency',
38
+ 'testConcurrency',
39
+ 'useDom',
40
+ 'enablePatterns',
41
+ 'ignoreDisplacements',
42
+ 'accessibilitySettings',
43
+ 'notifyOnCompletion',
44
+ 'batchNotify',
45
+ 'dontCloseBatches',
46
+ ];
47
+
48
+ module.exports = {configParams};
@@ -30,7 +30,7 @@ function errorDigest({passed, failed, diffs, logger, isInteractive}) {
30
30
  logger.log('errorDigest: diff errors', diffs);
31
31
  logger.log('errorDigest: test errors', failed);
32
32
 
33
- const testResultsUrl = diffs.length ? colorify(diffs[0].getUrl(), 'teal') : '';
33
+ const testResultsUrl = diffs.length ? colorify(diffs[0].url, 'teal') : '';
34
34
  const testResultsPrefix = testResultsUrl ? 'See details at:' : '';
35
35
  const footer = testResultsUrl
36
36
  ? `\n${indent()}${colorify(testResultsPrefix)} ${testResultsUrl}`
@@ -69,9 +69,9 @@ function errorDigest({passed, failed, diffs, logger, isInteractive}) {
69
69
  }
70
70
 
71
71
  function stringifyTestResults(testResults) {
72
- const hostDisplaySize = testResults.getHostDisplaySize();
73
- const viewport = hostDisplaySize ? `[${hostDisplaySize}]` : '';
74
- const testName = `${testResults.getName()} ${viewport}`;
72
+ const hostDisplaySize = testResults.hostDisplaySize;
73
+ const viewport = hostDisplaySize ? `[${hostDisplaySize.width}x${hostDisplaySize.height}]` : '';
74
+ const testName = `${testResults.name} ${viewport}`;
75
75
  return testName + (testResults.error ? ` : ${testResults.error}` : '');
76
76
  }
77
77
 
@@ -1,19 +1,18 @@
1
1
  'use strict';
2
-
3
2
  function getErrorsAndDiffs(testResultsArr) {
4
3
  return testResultsArr.reduce(
5
4
  ({failed, diffs, passed}, testResults) => {
6
5
  if (testResults instanceof Error || testResults.error) {
7
6
  failed.push(testResults);
8
7
  } else {
9
- const testStatus = testResults.getStatus();
8
+ const testStatus = testResults.status;
10
9
  if (testStatus === 'Passed') {
11
10
  passed.push(testResults);
12
11
  } else {
13
12
  if (testStatus === 'Unresolved') {
14
- if (testResults.getIsNew()) {
13
+ if (testResults.isNew) {
15
14
  testResults.error = new Error(
16
- `${testResults.getName()}. Please approve the new baseline at ${testResults.getUrl()}`,
15
+ `${testResults.name}. Please approve the new baseline at ${testResults.url}`,
17
16
  );
18
17
  failed.push(testResults);
19
18
  } else {
@@ -4,7 +4,7 @@ const getErrorsAndDiffs = require('./getErrorsAndDiffs');
4
4
  const {promisify} = require('util');
5
5
  const fs = require('fs');
6
6
  const writeFile = promisify(fs.writeFile);
7
- const {TestResultsFormatter} = require('@applitools/visual-grid-client');
7
+ const {formatters} = require('@applitools/core');
8
8
  const {resolve} = require('path');
9
9
 
10
10
  function printTestResults(testResultsArr) {
@@ -12,6 +12,7 @@ function printTestResults(testResultsArr) {
12
12
  level: testResultsArr.resultConfig.showLogs ? 'info' : 'silent',
13
13
  label: 'eyes',
14
14
  });
15
+ if (!testResultsArr.testResults) return;
15
16
  const {passed, failed, diffs} = getErrorsAndDiffs(testResultsArr.testResults);
16
17
  if ((failed.length || diffs.length) && !!testResultsArr.resultConfig.eyesFailCypressOnDiff) {
17
18
  throw new Error(
@@ -26,10 +27,12 @@ function printTestResults(testResultsArr) {
26
27
  }
27
28
  }
28
29
  function handleBatchResultsFile(results, tapFileConfig) {
29
- const formatter = new TestResultsFormatter(results);
30
30
  const fileName = tapFileConfig.tapFileName || `${new Date().toISOString()}-eyes.tap`;
31
31
  const tapFile = resolve(tapFileConfig.tapDirPath, fileName);
32
- return writeFile(tapFile, formatter.asHierarchicTAPString(false, true));
32
+ return writeFile(
33
+ tapFile,
34
+ formatters.toHierarchicTAPString(results, {includeSubTests: false, markNewAsPassed: true}),
35
+ );
33
36
  }
34
37
 
35
38
  module.exports = {printTestResults, handleBatchResultsFile};
@@ -1,5 +1,4 @@
1
1
  'use strict';
2
- const {TestResults} = require('@applitools/visual-grid-client');
3
2
  const handleTestResults = require('./handleTestResults');
4
3
 
5
4
  function makeGlobalRunHooks({closeManager, closeBatches, closeUniversalServer}) {
@@ -17,12 +16,10 @@ function makeGlobalRunHooks({closeManager, closeBatches, closeUniversalServer})
17
16
  isTextTerminal: config.isTextTerminal,
18
17
  };
19
18
  const summaries = await closeManager();
20
- const testResultsArr = [];
19
+
20
+ let testResults;
21
21
  for (const summary of summaries) {
22
- const testResults = summary.results.map(({testResults}) => testResults);
23
- for (const result of testResults) {
24
- testResultsArr.push(new TestResults(result));
25
- }
22
+ testResults = summary.results.map(({testResults}) => testResults);
26
23
  }
27
24
  if (!config.appliConfFile.dontCloseBatches) {
28
25
  await closeBatches({
@@ -34,13 +31,13 @@ function makeGlobalRunHooks({closeManager, closeBatches, closeUniversalServer})
34
31
  }
35
32
 
36
33
  if (config.appliConfFile.tapDirPath) {
37
- await handleTestResults.handleBatchResultsFile(testResultsArr, {
34
+ await handleTestResults.handleBatchResultsFile(testResults, {
38
35
  tapDirPath: config.appliConfFile.tapDirPath,
39
36
  tapFileName: config.appliConfFile.tapFileName,
40
37
  });
41
38
  }
42
39
 
43
- handleTestResults.printTestResults({testResults: testResultsArr, resultConfig});
40
+ handleTestResults.printTestResults({testResults, resultConfig});
44
41
  } finally {
45
42
  await closeUniversalServer();
46
43
  }
@@ -1,7 +1,6 @@
1
1
  'use strict';
2
2
  const connectSocket = require('./webSocket');
3
3
  const {makeServerProcess} = require('@applitools/eyes-universal');
4
- const {TestResults} = require('@applitools/visual-grid-client');
5
4
  const handleTestResults = require('./handleTestResults');
6
5
  const path = require('path');
7
6
  const fs = require('fs');
@@ -36,6 +35,7 @@ function makeStartServer({logger}) {
36
35
  cert: path.resolve(__dirname, '../pem/server.cert'),
37
36
  detached: false,
38
37
  idleTimeout: 0,
38
+ shutdownMode: 'stdin',
39
39
  });
40
40
 
41
41
  const managers = [];
@@ -69,18 +69,14 @@ function makeStartServer({logger}) {
69
69
  socketWithUniversal.send(newMessage);
70
70
  } else if (msg.name === 'Test.printTestResults') {
71
71
  try {
72
- const resultArr = [];
73
- for (const result of msg.payload.testResults) {
74
- resultArr.push(new TestResults(result));
75
- }
76
72
  if (msg.payload.resultConfig.tapDirPath) {
77
- handleTestResults.handleBatchResultsFile(resultArr, {
73
+ handleTestResults.handleBatchResultsFile(msg.payload.testResults, {
78
74
  tapFileName: msg.payload.resultConfig.tapFileName,
79
75
  tapDirPath: msg.payload.resultConfig.tapDirPath,
80
76
  });
81
77
  }
82
78
  handleTestResults.printTestResults({
83
- testResults: resultArr,
79
+ testResults: msg.payload.testResults,
84
80
  resultConfig: msg.payload.resultConfig,
85
81
  });
86
82
  socketWithClient.send(
@@ -0,0 +1,78 @@
1
+ 'use strict';
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+
6
+ function getCypressPaths({cwd, isCypress10}) {
7
+ if (isCypress10) {
8
+ return getCypressPaths10AndAbove(cwd);
9
+ } else {
10
+ return getCypressPaths9AndBelow(cwd);
11
+ }
12
+ }
13
+
14
+ function getCypressPaths10AndAbove(cwd) {
15
+ const cypressConfigPath = path.resolve(cwd, 'cypress.config.js');
16
+ if (fs.existsSync(cypressConfigPath)) {
17
+ const configContent = fs.readFileSync(cypressConfigPath, 'utf-8');
18
+ const supportFilePath = getSupportFilePathFromCypress10Config({cwd, configContent});
19
+ const typeScriptFilePath = supportFilePath
20
+ ? path.resolve(path.dirname(supportFilePath), 'index.d.ts')
21
+ : undefined;
22
+ return {
23
+ config: cypressConfigPath,
24
+ plugin: cypressConfigPath,
25
+ support: supportFilePath,
26
+ typescript: typeScriptFilePath,
27
+ };
28
+ } else {
29
+ throw new Error(
30
+ `No configuration file found at ${cypressConfigPath}. This is usually caused by setting up Eyes before setting up Cypress. Please run "npx cypress open" first.`,
31
+ );
32
+ }
33
+ }
34
+
35
+ function getSupportFilePathFromCypress10Config({cwd, configContent}) {
36
+ let supportFilePath;
37
+ if (configContent.includes('supportFile')) {
38
+ const regex = new RegExp(/(?:supportFile:)(?:\s*)(.*)/g);
39
+ const filePath = regex.exec(configContent)[1].replace(/['|"|,]*/g, '');
40
+ supportFilePath = path.resolve(cwd, filePath);
41
+ } else {
42
+ if (fs.existsSync(path.resolve(cwd, 'cypress/support/e2e.js'))) {
43
+ supportFilePath = path.resolve(cwd, 'cypress/support/e2e.js');
44
+ } else if (fs.existsSync(path.resolve(cwd, 'cypress/support/e2e.ts'))) {
45
+ supportFilePath = path.resolve(cwd, 'cypress/support/e2e.ts');
46
+ } else if (fs.existsSync(path.resolve(cwd, 'cypress/support/component.js'))) {
47
+ supportFilePath = path.resolve(cwd, 'cypress/support/component.js');
48
+ }
49
+ }
50
+ return supportFilePath;
51
+ }
52
+
53
+ function getCypressPaths9AndBelow(cwd) {
54
+ const cypressConfigPath = path.resolve(cwd, 'cypress.json');
55
+ if (fs.existsSync(cypressConfigPath)) {
56
+ try {
57
+ const configContent = JSON.parse(fs.readFileSync(cypressConfigPath));
58
+ const supportFilePath = path.resolve(configContent.supportFile || 'cypress/support/index.js');
59
+ const typeScriptFilePath = supportFilePath
60
+ ? path.resolve(path.dirname(supportFilePath), 'index.d.ts')
61
+ : undefined;
62
+ return {
63
+ config: cypressConfigPath,
64
+ plugin: path.resolve(cwd, configContent.pluginsFile || 'cypress/plugins/index.js'),
65
+ support: supportFilePath,
66
+ typescript: typeScriptFilePath,
67
+ };
68
+ } catch (err) {
69
+ throw new Error(`cypress.json at ${cypressConfigPath} is not a valid JSON: ${err.message}`);
70
+ }
71
+ } else {
72
+ throw new Error(
73
+ `No configuration file found at ${cypressConfigPath}. This is usually caused by setting up Eyes before setting up Cypress. Please run "npx cypress open" first.`,
74
+ );
75
+ }
76
+ }
77
+
78
+ module.exports = getCypressPaths;
@@ -0,0 +1,13 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const cwd = process.cwd();
4
+
5
+ function getCypressVersion() {
6
+ const cypressPackage = require.resolve('cypress', {paths: [cwd]});
7
+ const packageJson = JSON.parse(
8
+ fs.readFileSync(path.resolve(path.dirname(cypressPackage), 'package.json')),
9
+ );
10
+ return packageJson.version;
11
+ }
12
+
13
+ module.exports = getCypressVersion;
@@ -1,57 +1,23 @@
1
1
  'use strict';
2
2
 
3
3
  const fs = require('fs');
4
- const path = require('path');
5
-
6
4
  const chalk = require('chalk');
7
- const {readFileSync, writeFileSync} = require('fs');
8
5
  const addEyesCommands = require('./addEyesCommands');
9
6
  const isCommandsDefined = require('./isCommandsDefined');
10
- const getFilePath = require('./getFilePath');
11
- const getCypressConfig = require('./getCypressConfig');
12
-
13
- function handleCommands(cwd) {
14
- const cypressConfig = getCypressConfig(cwd);
15
- const commandsFilePath = getFilePath('support', cypressConfig, cwd);
16
- const commandsFileContent = readFileSync(commandsFilePath).toString();
17
-
18
- if (!isCommandsDefined(commandsFileContent)) {
19
- writeFileSync(commandsFilePath, addEyesCommands(commandsFileContent));
20
- console.log(chalk.cyan('Commands defined.'));
21
- } else {
22
- console.log(chalk.cyan('Commands already defined.'));
23
- }
24
- }
25
-
26
- function handlerCommandsCypress10(cwd) {
27
- const configContent = fs.readFileSync(path.resolve(cwd, 'cypress.config.js'), 'utf-8');
28
- let supportFilePath;
29
- if (configContent.includes('supportFile')) {
30
- const regex = new RegExp(/(?:supportFile:)(?:\s*)(.*)/g);
31
- const filePath = regex.exec(configContent)[1].replace(/['|"|,]*/g, '');
32
- supportFilePath = path.resolve(cwd, filePath);
33
- } else {
34
- if (fs.existsSync(path.resolve(cwd, 'cypress/support/e2e.js'))) {
35
- supportFilePath = path.resolve(cwd, 'cypress/support/e2e.js');
36
- } else if (fs.existsSync(path.resolve(cwd, 'cypress/support/e2e.ts'))) {
37
- supportFilePath = path.resolve(cwd, 'cypress/support/e2e.ts');
38
- } else if (fs.existsSync(path.resolve(cwd, 'cypress/support/component.js'))) {
39
- supportFilePath = path.resolve(cwd, 'cypress/support/component.js');
40
- }
41
- }
42
7
 
8
+ function handleCommands(supportFilePath) {
43
9
  if (supportFilePath) {
44
- const commandsFileContent = fs.readFileSync(supportFilePath, 'utf-8');
45
- if (!isCommandsDefined(commandsFileContent)) {
46
- writeFileSync(supportFilePath, addEyesCommands(commandsFileContent));
10
+ const supportFileContent = fs.readFileSync(supportFilePath, 'utf-8');
11
+
12
+ if (!isCommandsDefined(supportFileContent)) {
13
+ fs.writeFileSync(supportFilePath, addEyesCommands(supportFileContent));
47
14
  console.log(chalk.cyan('Commands defined.'));
48
15
  } else {
49
16
  console.log(chalk.cyan('Commands already defined.'));
50
17
  }
51
18
  } else {
52
- throw new Error('Commands file not found!');
19
+ throw new Error('Commands could not be defined. Support file could not be found');
53
20
  }
54
- return supportFilePath;
55
21
  }
56
22
 
57
- module.exports = {handleCommands, handlerCommandsCypress10};
23
+ module.exports = handleCommands;
@@ -1,31 +1,19 @@
1
1
  'use strict';
2
2
 
3
- const {readFileSync, writeFileSync} = require('fs');
4
3
  const chalk = require('chalk');
5
4
  const {addEyesCypressPlugin} = require('./addEyesCypressPlugin');
6
5
  const isPluginDefined = require('./isPluginDefined');
7
- const getFilePath = require('./getFilePath');
8
- const getCypressConfig = require('./getCypressConfig');
9
6
  const fs = require('fs');
10
- const path = require('path');
11
7
 
12
- function handlePlugin(cwd, isCypress10) {
13
- let fileContent, filePath;
14
- if (!isCypress10) {
15
- const cypressConfig = getCypressConfig(cwd);
16
- filePath = getFilePath('plugins', cypressConfig, cwd);
17
- fileContent = readFileSync(filePath).toString();
18
- } else {
19
- filePath = path.resolve(cwd, 'cypress.config.js');
20
- fileContent = fs.readFileSync(filePath, 'utf-8');
21
- }
8
+ function handlePlugin(pluginsFilePath) {
9
+ const fileContent = fs.readFileSync(pluginsFilePath, 'utf-8');
22
10
 
23
11
  if (!isPluginDefined(fileContent)) {
24
- writeFileSync(filePath, addEyesCypressPlugin(fileContent));
12
+ fs.writeFileSync(pluginsFilePath, addEyesCypressPlugin(fileContent));
25
13
  console.log(chalk.cyan('Plugins defined.'));
26
14
  } else {
27
15
  console.log(chalk.cyan('Plugins already defined'));
28
16
  }
29
17
  }
30
18
 
31
- module.exports = {handlePlugin};
19
+ module.exports = handlePlugin;
@@ -1,33 +1,15 @@
1
1
  'use strict';
2
2
  const chalk = require('chalk');
3
3
  const {writeFileSync, existsSync} = require('fs');
4
- const getFilePath = require('./getFilePath');
5
- const getCypressConfig = require('./getCypressConfig');
6
4
  const eyesIndexContent = `import "@applitools/eyes-cypress"`;
7
- const {resolve, dirname} = require('path');
8
5
 
9
- function handleTypeScript(cwd) {
10
- const cypressConfig = getCypressConfig(cwd);
11
- const typeScriptFilePath = getFilePath('typeScript', cypressConfig, cwd);
12
-
13
- if (!existsSync(typeScriptFilePath)) {
14
- writeFileSync(typeScriptFilePath, eyesIndexContent);
15
- console.log(chalk.cyan('Typescript defined.'));
16
- } else {
17
- console.log(chalk.cyan('Typescript already defined.'));
18
- }
19
- }
20
-
21
- function handlerTypeScriptCypress10(suportFilePath) {
22
- const supportDir = dirname(suportFilePath);
23
- const typeScriptFilePath = resolve(supportDir, 'index.d.ts');
6
+ function handleTypeScript(typeScriptFilePath) {
24
7
  if (!existsSync(typeScriptFilePath)) {
25
8
  writeFileSync(typeScriptFilePath, eyesIndexContent);
26
- console.log(chalk.cyan('Typescript defined.'));
9
+ console.log(chalk.cyan('TypeScript defined.'));
27
10
  } else {
28
- console.log(chalk.cyan('Typescript already defined.'));
11
+ console.log(chalk.cyan('TypeScript already defined.'));
29
12
  }
30
13
  }
31
14
 
32
- module.exports = {handleTypeScript, handlerTypeScriptCypress10};
33
- module.exports.eyesIndexContent = eyesIndexContent;
15
+ module.exports = {handleTypeScript, eyesIndexContent};
@@ -1,16 +0,0 @@
1
- 'use strict';
2
-
3
- const {readFileSync} = require('fs');
4
- const {resolve} = require('path');
5
- const chalk = require('chalk');
6
-
7
- function getCypressConfig(cwd) {
8
- const cypressConfigPath = resolve(cwd, 'cypress.json');
9
- try {
10
- return JSON.parse(readFileSync(cypressConfigPath));
11
- } catch (ex) {
12
- console.log(chalk.red('cypress.json not found at ', cypressConfigPath));
13
- }
14
- }
15
-
16
- module.exports = getCypressConfig;