@applitools/eyes-cypress 3.26.3 → 3.26.6

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,26 @@
9
9
 
10
10
 
11
11
 
12
+ ## 3.26.6 - 2022/7/15
13
+
14
+ ### Features
15
+ - Internal architecture fixes
16
+ ### Bug fixes
17
+
18
+ ## 3.26.5 - 2022/7/12
19
+
20
+ ### Features
21
+ ### Bug fixes
22
+ - Support string tag name in eyesCheck
23
+
24
+ ## 3.26.4 - 2022/7/7
25
+
26
+ ### Features
27
+ - Add support for cypress 10
28
+ ### Bug fixes
29
+ - Fix use cases where we fail to serialize elements
30
+ - Fixed bug where a failure in a single UFG environment fails all other environments in the same configuration
31
+
12
32
  ## 3.26.3 - 2022/6/17
13
33
 
14
34
  ### Features
package/README.md CHANGED
@@ -27,9 +27,12 @@ The above command will add the necessary imports to your cypress `pluginsFile` a
27
27
  #### Manual configuration
28
28
 
29
29
  ##### 1. Configure Eyes-Cypress plugin
30
-
30
+ <br>
31
+
31
32
  Eyes-Cypress acts as a [Cypress plugin](https://docs.cypress.io/guides/tooling/plugins-guide.html), so it should be configured as such.
32
- Unfortunately there's no easy way to do this automatically, so you need to manually add the following code to your `pluginsFile`:
33
+ Unfortunately there's no easy way to do this automatically, so you need to manually:
34
+ #### Cypress version < 10:
35
+ Add the following code to your `pluginsFile`:
33
36
 
34
37
  **Important**: add this code **after** the definition of `module.exports`:
35
38
 
@@ -38,7 +41,16 @@ require('@applitools/eyes-cypress')(module)
38
41
  ```
39
42
 
40
43
  Normally, this is `cypress/plugins/index.js`. You can read more about it in Cypress' docs [here](https://docs.cypress.io/guides/references/configuration.html#Folders-Files).
44
+ <br>
45
+
46
+ #### Cypress version >= 10:
41
47
 
48
+ Add the following code to your `cypress.config.js` file after `module.exports`:
49
+
50
+ ```js
51
+ require('@applitools/eyes-cypress')(module)
52
+ ```
53
+ This file is normally at the root of the project
42
54
  ##### 2. Configure custom commands
43
55
 
44
56
  Eyes-Cypress exposes new commands to your tests. This means that more methods will be available on the `cy` object. To enable this, it's required to configure these custom commands.
@@ -48,7 +60,7 @@ As with the plugin, there's no automatic way to configure this in cypress, so yo
48
60
  import '@applitools/eyes-cypress/commands'
49
61
  ```
50
62
 
51
- Normally, this is `cypress/support/index.js`. You can read more about it in Cypress' docs [here](https://docs.cypress.io/guides/references/configuration.html#Folders-Files).
63
+ Normally, this is `cypress/support/index.js` for cypress version < 10 and `cypress/support/e2e.js` for cypress version >= 10. You can read more about it in Cypress' docs [here](https://docs.cypress.io/guides/references/configuration.html#Folders-Files).
52
64
 
53
65
  ##### 3. (Optional) TypeScript configuration
54
66
 
@@ -66,8 +78,6 @@ Add this file to your project with either:
66
78
  ```
67
79
  cp node_modules/@applitools/eyes-cypress/eyes-index.d.ts ./cypress/support/
68
80
  ```
69
-
70
-
71
81
  ### Applitools API key
72
82
 
73
83
  In order to authenticate via the Applitools server, you need to supply the Eyes-Cypress SDK with the API key you got from Applitools. Read more about how to obtain the API key [here](https://applitools.com/docs/topics/overview/obtain-api-key.html).
package/bin/eyes-setup.js CHANGED
@@ -2,18 +2,34 @@
2
2
  'use strict';
3
3
 
4
4
  const chalk = require('chalk');
5
- const handlePlugin = require('../src/setup/handlePlugin');
6
- const handleCommands = require('../src/setup/handleCommands');
7
- const handleTypeScript = require('../src/setup/handleTypeScript');
5
+ const {handlePlugin} = require('../src/setup/handlePlugin');
6
+ const {handleCommands, handlerCommandsCypress10} = require('../src/setup/handleCommands');
7
+ const {handleTypeScript, handlerTypeScriptCypress10} = require('../src/setup/handleTypeScript');
8
8
  const {version} = require('../package');
9
+ const fs = require('fs');
9
10
  const cwd = process.cwd();
10
11
 
11
12
  console.log(chalk.cyan('Setup eyes-cypress', version));
13
+ const packageJson = JSON.parse(fs.readFileSync('package.json'));
14
+ let cypressVersion;
12
15
 
16
+ if (packageJson.dependencies && packageJson.dependencies.cypress) {
17
+ cypressVersion = packageJson.dependencies.cypress;
18
+ } else if (packageJson.devDependencies && packageJson.devDependencies.cypress) {
19
+ cypressVersion = packageJson.devDependencies.cypress;
20
+ }
21
+ console.log(chalk.cyan('Cypress version that was found', cypressVersion));
22
+ const isCypress10 = parseFloat(cypressVersion, 10) >= 10 ? true : false;
13
23
  try {
14
- handlePlugin(cwd);
15
- handleCommands(cwd);
16
- handleTypeScript(cwd);
24
+ if (!isCypress10) {
25
+ handlePlugin(cwd, isCypress10);
26
+ handleCommands(cwd);
27
+ handleTypeScript(cwd);
28
+ } else {
29
+ handlePlugin(cwd, isCypress10);
30
+ const supportFilePath = handlerCommandsCypress10(cwd);
31
+ handlerTypeScriptCypress10(supportFilePath);
32
+ }
17
33
  } catch (e) {
18
34
  console.log(chalk.red('Setup error:\n', e));
19
35
  }
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@applitools/eyes-cypress",
3
- "version": "3.26.3",
3
+ "version": "3.26.6",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git://github.com/applitools/eyes.sdk.javascript1.git",
7
- "directory": "packages/eyes-cypress"
7
+ "directory": "js/packages/eyes-cypress"
8
8
  },
9
9
  "license": "SEE LICENSE IN LICENSE",
10
10
  "aliases": [
@@ -29,17 +29,18 @@
29
29
  "build": "tsc",
30
30
  "generate:tests": "coverage-tests generate",
31
31
  "test": "yarn test:unit && yarn test:it && yarn test:e2e && yarn test:ts && yarn test:coverage",
32
+ "test:sanity": "yarn test:unit && yarn test:it && yarn test:ts",
32
33
  "test:unit": "mocha --no-timeouts 'test/unit/**/*.test.js'",
33
- "test:it": "mocha --no-timeouts 'test/it/**/*.test.js'",
34
- "test:e2e": "mkdir -p test/fixtures/testAppCopies && mocha --no-timeouts 'test/e2e/**/*.test.js'",
34
+ "test:it": "yarn build && mocha --no-timeouts 'test/it/**/*.test.js'",
35
+ "test:ts": "yarn test:ts:compile && yarn test:ts:run",
35
36
  "test:ts:compile": "tsc --project test/e2e/ts/cypress",
36
37
  "test:ts:run": "cypress run --config-file test/e2e/ts/cypress-ts.json",
37
- "test:ts": "yarn test:ts:compile && yarn test:ts:run",
38
- "test:coverage": "yarn generate:tests && cd test/coverage/generic && unset APPLITOOLS_API_KEY && APPLITOOLS_BATCH_NAME='JS Coverage Tests: eyes-selenium' APPLITOOLS_BATCH_ID=$(uuidgen) cypress run",
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",
39
+ "test:e2e": "mkdir -p test/fixtures/testAppCopies && mocha --no-timeouts 'test/e2e/**/*.test.js'",
39
40
  "cypress": "cypress open --config-file test/fixtures/cypress-play.json",
40
- "cypress:new": "node_modules/cypress-new/bin/cypress open --config-file test/fixtures/cypress-play.json",
41
+ "cypress:new": "cd test/play && yarn && npx cypress open",
41
42
  "cypress:run": "cypress run --config-file test/fixtures/cypress-play.json --spec=test/fixtures/testApp/cypress/integration-play/play.js",
42
- "cypress:run:new": "node_modules/cypress-new/bin/cypress run --config-file test/fixtures/cypress-play.json --spec=test/fixtures/testApp/cypress/integration-play/play.js",
43
+ "cypress:run:new": "cd test/play && yarn && npx cypress run --spec=../fixtures/testApp/cypress/integration-play/play.js",
43
44
  "cypress:play": "cd test/fixtures/testApp && cypress run --config integrationFolder=cypress/integration-play,pluginsFile=cypress/plugins/index-play.js,supportFile=cypress/support/index-run.js --spec=cypress/integration-play/play.js",
44
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",
45
46
  "prepublish:setup": "sudo apt-get install xvfb",
@@ -54,24 +55,24 @@
54
55
  }
55
56
  },
56
57
  "dependencies": {
57
- "@applitools/eyes-api": "1.7.0",
58
- "@applitools/eyes-universal": "2.9.1",
58
+ "@applitools/eyes-api": "1.7.4",
59
+ "@applitools/eyes-universal": "2.9.7",
59
60
  "@applitools/functional-commons": "1.6.0",
60
- "@applitools/logger": "1.1.12",
61
- "@applitools/visual-grid-client": "15.12.45",
61
+ "@applitools/logger": "1.1.15",
62
+ "@applitools/visual-grid-client": "15.13.6",
62
63
  "chalk": "3.0.0",
63
64
  "uuid": "8.3.2",
64
65
  "ws": "8.5.0"
65
66
  },
66
67
  "devDependencies": {
67
- "@applitools/bongo": "^2.1.5",
68
+ "@applitools/bongo": "^2.1.6",
68
69
  "@applitools/scripts": "1.1.0",
69
- "@applitools/sdk-coverage-tests": "^2.3.18",
70
+ "@applitools/sdk-coverage-tests": "^2.3.19",
70
71
  "@applitools/snaptdout": "1.0.1",
71
- "@applitools/test-server": "1.1.1",
72
- "@applitools/test-utils": "1.3.3",
73
- "@applitools/types": "^1.5.3",
74
- "@applitools/utils": "1.3.8",
72
+ "@applitools/test-server": "1.1.4",
73
+ "@applitools/test-utils": "1.4.2",
74
+ "@applitools/types": "^1.5.5",
75
+ "@applitools/utils": "1.3.10",
75
76
  "@types/node": "12",
76
77
  "@types/ws": "^8.2.2",
77
78
  "@typescript-eslint/eslint-plugin": "^5.10.2",
@@ -79,8 +80,7 @@
79
80
  "chai": "4.2.0",
80
81
  "chai-spies": "1.0.0",
81
82
  "cookie-parser": "1.4.4",
82
- "cypress": "6.5.0",
83
- "cypress-new": "npm:cypress@9",
83
+ "cypress": "8.0.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",
@@ -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',
@@ -12,6 +15,7 @@ function eyesCheckMapValues({args, refer}) {
12
15
  'accessibility',
13
16
  'region',
14
17
  'selector',
18
+ 'element',
15
19
  ];
16
20
 
17
21
  let regionSettings = {};
@@ -5,8 +5,9 @@ function isGlobalHooksSupported(config) {
5
5
  const {version, experimentalRunEvents} = config;
6
6
 
7
7
  return (
8
- version >= CYPRESS_NO_FLAG_VERSION ||
9
- (version >= CYPRESS_SUPPORTED_VERSION && !!experimentalRunEvents)
8
+ parseFloat(version, 10) >= parseFloat(CYPRESS_NO_FLAG_VERSION, 10) ||
9
+ (parseFloat(version, 10) >= parseFloat(CYPRESS_SUPPORTED_VERSION, 10) &&
10
+ !!experimentalRunEvents)
10
11
  );
11
12
  }
12
13
 
@@ -6,8 +6,10 @@ const makeGlobalRunHooks = require('./hooks');
6
6
  function makePluginExport({startServer, eyesConfig}) {
7
7
  return function pluginExport(pluginModule) {
8
8
  let eyesServer;
9
- const pluginModuleExports = pluginModule.exports;
10
- pluginModule.exports = async function(...args) {
9
+ const pluginModuleExports = pluginModule.exports.e2e
10
+ ? pluginModule.exports.e2e.setupNodeEvents
11
+ : pluginModule.exports;
12
+ const setupNodeEvents = async function(...args) {
11
13
  const {server, port, closeManager, closeBatches, closeUniversalServer} = await startServer();
12
14
  eyesServer = server;
13
15
 
@@ -51,6 +53,11 @@ function makePluginExport({startServer, eyesConfig}) {
51
53
  }
52
54
  }
53
55
  };
56
+ if (pluginModule.exports.e2e) {
57
+ pluginModule.exports.e2e.setupNodeEvents = setupNodeEvents;
58
+ } else {
59
+ pluginModule.exports = setupNodeEvents;
60
+ }
54
61
  return function getCloseServer() {
55
62
  return eyesServer.close();
56
63
  };
@@ -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) {
@@ -11,5 +11,4 @@ function addEyesCypressPlugin(content) {
11
11
  }
12
12
  }
13
13
 
14
- module.exports = addEyesCypressPlugin;
15
- module.exports.pluginRequire = pluginRequire;
14
+ module.exports = {addEyesCypressPlugin, pluginRequire};
@@ -1,5 +1,8 @@
1
1
  'use strict';
2
2
 
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+
3
6
  const chalk = require('chalk');
4
7
  const {readFileSync, writeFileSync} = require('fs');
5
8
  const addEyesCommands = require('./addEyesCommands');
@@ -20,4 +23,33 @@ function handleCommands(cwd) {
20
23
  }
21
24
  }
22
25
 
23
- module.exports = handleCommands;
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/component.js'))) {
37
+ supportFilePath = path.resolve(cwd, 'cypress/support/component.js');
38
+ }
39
+ }
40
+
41
+ if (supportFilePath) {
42
+ const commandsFileContent = fs.readFileSync(supportFilePath, 'utf-8');
43
+ if (!isCommandsDefined(commandsFileContent)) {
44
+ writeFileSync(supportFilePath, addEyesCommands(commandsFileContent));
45
+ console.log(chalk.cyan('Commands defined.'));
46
+ } else {
47
+ console.log(chalk.cyan('Commands already defined.'));
48
+ }
49
+ } else {
50
+ throw new Error('Commands file not found!');
51
+ }
52
+ return supportFilePath;
53
+ }
54
+
55
+ module.exports = {handleCommands, handlerCommandsCypress10};
@@ -2,22 +2,30 @@
2
2
 
3
3
  const {readFileSync, writeFileSync} = require('fs');
4
4
  const chalk = require('chalk');
5
- const addEyesCypressPlugin = require('./addEyesCypressPlugin');
5
+ const {addEyesCypressPlugin} = require('./addEyesCypressPlugin');
6
6
  const isPluginDefined = require('./isPluginDefined');
7
7
  const getFilePath = require('./getFilePath');
8
8
  const getCypressConfig = require('./getCypressConfig');
9
+ const fs = require('fs');
10
+ const path = require('path');
9
11
 
10
- function handlePlugin(cwd) {
11
- const cypressConfig = getCypressConfig(cwd);
12
- const pluginsFilePath = getFilePath('plugins', cypressConfig, cwd);
13
- const pluginsFileContent = readFileSync(pluginsFilePath).toString();
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
+ }
14
22
 
15
- if (!isPluginDefined(pluginsFileContent)) {
16
- writeFileSync(pluginsFilePath, addEyesCypressPlugin(pluginsFileContent));
23
+ if (!isPluginDefined(fileContent)) {
24
+ writeFileSync(filePath, addEyesCypressPlugin(fileContent));
17
25
  console.log(chalk.cyan('Plugins defined.'));
18
26
  } else {
19
27
  console.log(chalk.cyan('Plugins already defined'));
20
28
  }
21
29
  }
22
30
 
23
- module.exports = handlePlugin;
31
+ module.exports = {handlePlugin};
@@ -4,6 +4,7 @@ const {writeFileSync, existsSync} = require('fs');
4
4
  const getFilePath = require('./getFilePath');
5
5
  const getCypressConfig = require('./getCypressConfig');
6
6
  const eyesIndexContent = `import "@applitools/eyes-cypress"`;
7
+ const {resolve, dirname} = require('path');
7
8
 
8
9
  function handleTypeScript(cwd) {
9
10
  const cypressConfig = getCypressConfig(cwd);
@@ -17,5 +18,16 @@ function handleTypeScript(cwd) {
17
18
  }
18
19
  }
19
20
 
20
- module.exports = handleTypeScript;
21
+ function handlerTypeScriptCypress10(suportFilePath) {
22
+ const supportDir = dirname(suportFilePath);
23
+ const typeScriptFilePath = resolve(supportDir, 'index.d.ts');
24
+ if (!existsSync(typeScriptFilePath)) {
25
+ writeFileSync(typeScriptFilePath, eyesIndexContent);
26
+ console.log(chalk.cyan('Typescript defined.'));
27
+ } else {
28
+ console.log(chalk.cyan('Typescript already defined.'));
29
+ }
30
+ }
31
+
32
+ module.exports = {handleTypeScript, handlerTypeScriptCypress10};
21
33
  module.exports.eyesIndexContent = eyesIndexContent;