@applitools/eyes-cypress 3.26.4 → 3.27.0

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
@@ -9,6 +9,27 @@
9
9
 
10
10
 
11
11
 
12
+ ## 3.27.0 - 2022/7/25
13
+
14
+ ### Features
15
+ - Add support for padded coded regions
16
+ - Add support for dynamic coded regions
17
+ ### Bug fixes
18
+ - Fix `npx eyes-setup` for Cypress version with a caret, support `e2e.ts` as support file
19
+ - Better support in DOM slot element
20
+
21
+ ## 3.26.6 - 2022/7/15
22
+
23
+ ### Features
24
+ - Internal architecture fixes
25
+ ### Bug fixes
26
+
27
+ ## 3.26.5 - 2022/7/12
28
+
29
+ ### Features
30
+ ### Bug fixes
31
+ - Support string tag name in eyesCheck
32
+
12
33
  ## 3.26.4 - 2022/7/7
13
34
 
14
35
  ### Features
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Eyes-Cypress
1
+ # Eyes-Cypress
2
2
 
3
3
  Applitools Eyes SDK for [Cypress](https://www.cypress.io/).
4
4
 
@@ -213,6 +213,7 @@ Applitools will take screenshots and perform the visual comparisons in the backg
213
213
  - [`layout`](#layout)
214
214
  - [`strict`](#strict)
215
215
  - [`content`](#content)
216
+ - [`padded coded regions`](#padded-coded-regions)
216
217
  - [`accessibility`](#accessibility)
217
218
  - [`region in shadow DOM`](#region-in-shadow-dom)
218
219
  - [`scriptHooks`](#scripthooks)
@@ -224,6 +225,8 @@ Applitools will take screenshots and perform the visual comparisons in the backg
224
225
  - [`enablePatterns`](#enablepatterns)
225
226
  - [`matchLevel`](#matchlevel)
226
227
  - [`visualGridOptions`](#visualgridoptions)
228
+ - [`coded regions-regionId`](#regionId)
229
+ - [`lazy loading`](#lazy-loading)
227
230
  - [Close](#close)
228
231
  - [GetAllTestResults](#getalltestresults)
229
232
  - [deleteTestResults](#deletetestresults)
@@ -492,6 +495,22 @@ cy.get('.some-div-to-float').then($el => {
492
495
  })
493
496
  ```
494
497
 
498
+ ##### `padded coded regions`
499
+
500
+ ```js
501
+ cy.get('some-region').then(el => {
502
+ cy.eyesCheckWindow({
503
+ // will add pedding to a region by a css selector at the left and top of the region
504
+ layout: {region: 'layout-region', padding: {left:20, top: 10}}
505
+ // will add padding of 20px to all JQuery elements at the top, button, right and left of the region
506
+ ignore: {element: el, padding: 20},
507
+ // will add padding for a DOM element on the top of the region
508
+ content: {element: el[0], padding: {top:10}}
509
+ })
510
+
511
+ })
512
+ ```
513
+
495
514
  ##### `accessibility`
496
515
 
497
516
  (optional): A single or an array of regions to perform accessibility checks, For example:
@@ -634,6 +653,38 @@ cy.eyesCheckWindow({
634
653
  }
635
654
  })
636
655
  ```
656
+ #### regionId
657
+
658
+ The regionId can be automaticaly set from the region that is passed or can be explicitly sent using `regionId` property
659
+
660
+ ```js
661
+ cy.get('.region.two:nth-child(2)').then(el => {
662
+ cy.eyesCheckWindow({
663
+ fully: false,
664
+ ignore: [
665
+ {type: 'css', selector: '.region.three:nth-child(3n)'},
666
+ {type: 'xpath', selector: '//div[@class="region one"][3]'},
667
+ {element: el, regionId: 'my-region-id'},
668
+ ],
669
+ });
670
+ })
671
+ ```
672
+ #### lazy loading
673
+
674
+ It's possible to have the SDK scroll the entire page (or a specific length of the page) to make sure all lazyily loaded assets are on the page before performing a check.
675
+
676
+ ```js
677
+ // lazy loads with sensible defaults
678
+ cy.eyesCheckWindow(lazyload:{})
679
+
680
+ // lazy loads with options specified
681
+ cy.eyesCheckWindow({lazyLoad: {
682
+ maxAmountToScroll: 1000, // total pixels of the page to be scrolled
683
+ scrollLength: 250, // amount of pixels to use for each scroll attempt
684
+ waitingTime: 500, // milliseconds to wait in-between each scroll attempt
685
+ }})
686
+ ```
687
+
637
688
 
638
689
  #### Close
639
690
 
package/bin/eyes-setup.js CHANGED
@@ -8,6 +8,7 @@ const {handleTypeScript, handlerTypeScriptCypress10} = require('../src/setup/han
8
8
  const {version} = require('../package');
9
9
  const fs = require('fs');
10
10
  const cwd = process.cwd();
11
+ const semver = require('semver');
11
12
 
12
13
  console.log(chalk.cyan('Setup eyes-cypress', version));
13
14
  const packageJson = JSON.parse(fs.readFileSync('package.json'));
@@ -18,17 +19,18 @@ if (packageJson.dependencies && packageJson.dependencies.cypress) {
18
19
  } else if (packageJson.devDependencies && packageJson.devDependencies.cypress) {
19
20
  cypressVersion = packageJson.devDependencies.cypress;
20
21
  }
21
- console.log(chalk.cyan('Cypress version that was found', cypressVersion));
22
- const isCypress10 = parseFloat(cypressVersion, 10) >= 10 ? true : false;
22
+ const logStr = `Cypress version that was found ${cypressVersion}`;
23
23
  try {
24
- if (!isCypress10) {
25
- handlePlugin(cwd, isCypress10);
26
- handleCommands(cwd);
27
- handleTypeScript(cwd);
28
- } else {
29
- handlePlugin(cwd, isCypress10);
24
+ if (semver.satisfies(semver.coerce(String(cypressVersion)), '>=10.0.0')) {
25
+ console.log(chalk.cyan(logStr, ' (above v10 handler)'));
26
+ handlePlugin(cwd, true);
30
27
  const supportFilePath = handlerCommandsCypress10(cwd);
31
28
  handlerTypeScriptCypress10(supportFilePath);
29
+ } else {
30
+ console.log(chalk.cyan(logStr));
31
+ handlePlugin(cwd, false);
32
+ handleCommands(cwd);
33
+ handleTypeScript(cwd);
32
34
  }
33
35
  } catch (e) {
34
36
  console.log(chalk.red('Setup error:\n', e));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applitools/eyes-cypress",
3
- "version": "3.26.4",
3
+ "version": "3.27.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git://github.com/applitools/eyes.sdk.javascript1.git",
@@ -56,10 +56,10 @@
56
56
  },
57
57
  "dependencies": {
58
58
  "@applitools/eyes-api": "1.7.4",
59
- "@applitools/eyes-universal": "2.9.6",
59
+ "@applitools/eyes-universal": "2.9.12",
60
60
  "@applitools/functional-commons": "1.6.0",
61
61
  "@applitools/logger": "1.1.15",
62
- "@applitools/visual-grid-client": "15.13.6",
62
+ "@applitools/visual-grid-client": "15.13.11",
63
63
  "chalk": "3.0.0",
64
64
  "uuid": "8.3.2",
65
65
  "ws": "8.5.0"
@@ -70,8 +70,8 @@
70
70
  "@applitools/sdk-coverage-tests": "^2.3.19",
71
71
  "@applitools/snaptdout": "1.0.1",
72
72
  "@applitools/test-server": "1.1.4",
73
- "@applitools/test-utils": "1.4.2",
74
- "@applitools/types": "^1.5.5",
73
+ "@applitools/test-utils": "1.4.3",
74
+ "@applitools/types": "^1.5.7",
75
75
  "@applitools/utils": "1.3.10",
76
76
  "@types/node": "12",
77
77
  "@types/ws": "^8.2.2",
@@ -92,6 +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",
95
96
  "typescript": "4.6.4"
96
97
  },
97
98
  "engines": {
@@ -116,7 +116,6 @@ Cypress.Commands.add('eyesOpen', function(args = {}) {
116
116
  name: 'eyes.cypress',
117
117
  version: require('../../package.json').version,
118
118
  commands: Object.keys(spec).concat(['isSelector', 'isDriver', 'isElement']), // TODO fix spec.isSelector and spec.isDriver and spec.isElement in driver utils
119
- cwd: process.cwd(),
120
119
  });
121
120
 
122
121
  manager =
@@ -1,5 +1,8 @@
1
1
  /* global Node */
2
2
  function eyesCheckMapValues({args, refer}) {
3
+ if (typeof args === `string`) {
4
+ args = {tag: args};
5
+ }
3
6
  const config = args; // just did it for having less git changes at this moment
4
7
  const mappedValues = [
5
8
  'tag',
@@ -20,11 +23,11 @@ function eyesCheckMapValues({args, refer}) {
20
23
  const checkSettings = {
21
24
  name: config.tag,
22
25
  hooks: config.scriptHooks,
23
- ignoreRegions: refElements(config.ignore),
26
+ ignoreRegions: convertPaddedRegion(config.ignore),
24
27
  floatingRegions: convertFloatingRegion(config.floating),
25
- strictRegions: refElements(config.strict),
26
- layoutRegions: refElements(config.layout),
27
- contentRegions: refElements(config.content),
28
+ strictRegions: convertPaddedRegion(config.strict),
29
+ layoutRegions: convertPaddedRegion(config.layout),
30
+ contentRegions: convertPaddedRegion(config.content),
28
31
  accessibilityRegions: convertAccessabilityRegions(config.accessibility),
29
32
  };
30
33
 
@@ -79,6 +82,34 @@ function eyesCheckMapValues({args, refer}) {
79
82
 
80
83
  // #region helper functions
81
84
 
85
+ function convertPaddedRegion(regions) {
86
+ if (!regions) return;
87
+ if (!Array.isArray(regions)) regions = [regions];
88
+ let resRegions = [];
89
+ for (const region of regions) {
90
+ if (region.element || isHTMLElement(region) || region.jquery) {
91
+ if (region.padding || region.regionId) {
92
+ let currRefElements = refElements(region.element);
93
+ for (const refElement of currRefElements) {
94
+ let curr = {region: refElement};
95
+ if (region.padding) {
96
+ curr.padding = region.padding;
97
+ }
98
+ if (region.regionId) {
99
+ curr.regionId = region.regionId;
100
+ }
101
+ resRegions.push(curr);
102
+ }
103
+ } else {
104
+ resRegions = [...resRegions, ...refElements(region)];
105
+ }
106
+ } else {
107
+ resRegions.push(region);
108
+ }
109
+ }
110
+ return resRegions;
111
+ }
112
+
82
113
  function convertAccessabilityRegions(accessibilityRegions) {
83
114
  if (!accessibilityRegions) return accessibilityRegions;
84
115
  const accessibility = [];
@@ -61,7 +61,7 @@ export function setViewportSize(vs: any): void {
61
61
  export function transformSelector(selector: Selector): Selector {
62
62
  if (selector.hasOwnProperty('selector') && (!selector.hasOwnProperty('type') || (selector as EyesSelector).type === 'css')) {
63
63
  return (selector as EyesSelector).selector
64
- }
64
+ }
65
65
  return selector
66
66
  }
67
67
 
@@ -34,6 +34,8 @@ function makeStartServer({logger}) {
34
34
  const {port: universalPort, close: closeUniversalServer} = await makeServerProcess({
35
35
  key: path.resolve(__dirname, '../pem/server.key'),
36
36
  cert: path.resolve(__dirname, '../pem/server.cert'),
37
+ detached: false,
38
+ idleTimeout: 0,
37
39
  });
38
40
 
39
41
  const managers = [];
@@ -55,7 +57,17 @@ function makeStartServer({logger}) {
55
57
  socketWithClient.on('message', message => {
56
58
  const msg = JSON.parse(message);
57
59
  logger.log('==> ', message.toString().slice(0, 1000));
58
- if (msg.name === 'Test.printTestResults') {
60
+ if (msg.name === 'Core.makeSDK') {
61
+ const newMessage = Buffer.from(
62
+ JSON.stringify({
63
+ name: msg.name,
64
+ key: msg.key,
65
+ payload: Object.assign(msg.payload, {cwd: process.cwd()}),
66
+ }),
67
+ 'utf-8',
68
+ );
69
+ socketWithUniversal.send(newMessage);
70
+ } else if (msg.name === 'Test.printTestResults') {
59
71
  try {
60
72
  const resultArr = [];
61
73
  for (const result of msg.payload.testResults) {
@@ -33,6 +33,8 @@ function handlerCommandsCypress10(cwd) {
33
33
  } else {
34
34
  if (fs.existsSync(path.resolve(cwd, 'cypress/support/e2e.js'))) {
35
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');
36
38
  } else if (fs.existsSync(path.resolve(cwd, 'cypress/support/component.js'))) {
37
39
  supportFilePath = path.resolve(cwd, 'cypress/support/component.js');
38
40
  }