@applitools/eyes-cypress 3.29.1 → 3.30.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 +15 -0
- package/README.md +34 -10
- package/dist/plugin/hooks.js +4 -4
- package/dist/plugin/pluginExport.js +3 -3
- package/dist/plugin/server.js +8 -9
- package/package.json +18 -22
- package/src/browser/commands.js +43 -30
- package/src/browser/eyesCheckMapping.js +75 -37
- package/src/browser/eyesOpenMapping.js +21 -27
- package/src/expose.ts +5 -3
- package/src/plugin/hooks.ts +10 -5
- package/src/plugin/index.ts +1 -0
- package/src/plugin/pluginExport.ts +10 -3
- package/src/plugin/server.ts +25 -12
- package/src/setup/handlePlugin.js +1 -1
- package/types/expose.d.ts +53 -52
package/CHANGELOG.md
CHANGED
|
@@ -12,6 +12,21 @@
|
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
|
|
15
|
+
## 3.30.1 - 2023/3/22
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
### Bug fixes
|
|
19
|
+
- Fixed cypress 8 not working with core v2
|
|
20
|
+
- Fixed closeBatch issue
|
|
21
|
+
|
|
22
|
+
## 3.30.0 - 2023/3/19
|
|
23
|
+
|
|
24
|
+
### Features
|
|
25
|
+
- Crop screenshot image base on account info
|
|
26
|
+
### Bug fixes
|
|
27
|
+
- Fixed slowness during ufg tests
|
|
28
|
+
- Upgrade to core@v2
|
|
29
|
+
|
|
15
30
|
## 3.29.1 - 2023/2/2
|
|
16
31
|
|
|
17
32
|
### Features
|
package/README.md
CHANGED
|
@@ -108,17 +108,23 @@ For `typescript` use you must add the following code to your `tsconfig.json`:
|
|
|
108
108
|
|
|
109
109
|
Eyes-Cypress ships with official type declarations for TypeScript. This allows you to add eyes commands to your TypeScript tests.
|
|
110
110
|
|
|
111
|
-
Add this file to your project
|
|
111
|
+
Add this file to your project using one of the following two options:
|
|
112
112
|
1. Adding the path to your [tsconfig](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html) file:
|
|
113
|
+
|
|
114
|
+
```json
|
|
115
|
+
{
|
|
116
|
+
...
|
|
117
|
+
"compilerOptions": {
|
|
118
|
+
...
|
|
119
|
+
"types": ["@applitools/eyes-cypress", "cypress", "node"]
|
|
120
|
+
...
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
2. Create `index.d.ts` file under `cypress/support` folder that contains:
|
|
113
126
|
```
|
|
114
|
-
|
|
115
|
-
"files": ["./node_modules/@applitools/eyes-cypress/index.d.ts"],
|
|
116
|
-
...
|
|
117
|
-
}
|
|
118
|
-
```
|
|
119
|
-
2. Copying the file to to your [cypress/support/](https://docs.cypress.io/guides/core-concepts/writing-and-organizing-tests.html#Folder-Structure) dir:
|
|
120
|
-
```
|
|
121
|
-
cp node_modules/@applitools/eyes-cypress/index.d.ts ./cypress/support/
|
|
127
|
+
import "@applitools/eyes-cypress"
|
|
122
128
|
```
|
|
123
129
|
### Applitools API key
|
|
124
130
|
|
|
@@ -269,6 +275,7 @@ Applitools will take screenshots and perform the visual comparisons in the backg
|
|
|
269
275
|
- [`visualGridOptions`](#visualgridoptions)
|
|
270
276
|
- [`coded regions-regionId`](#regionId)
|
|
271
277
|
- [`lazy loading`](#lazy-loading)
|
|
278
|
+
- [Density metrics](#density-metrics-densitymetrics)
|
|
272
279
|
- [Close](#close)
|
|
273
280
|
- [GetAllTestResults](#getalltestresults)
|
|
274
281
|
- [deleteTestResults](#deletetestresults)
|
|
@@ -751,7 +758,7 @@ It's possible to have the SDK scroll the entire page (or a specific length of th
|
|
|
751
758
|
|
|
752
759
|
```js
|
|
753
760
|
// lazy loads with sensible defaults
|
|
754
|
-
cy.eyesCheckWindow(lazyload:{})
|
|
761
|
+
cy.eyesCheckWindow({lazyload:{}})
|
|
755
762
|
|
|
756
763
|
// lazy loads with options specified
|
|
757
764
|
cy.eyesCheckWindow({lazyLoad: {
|
|
@@ -761,6 +768,23 @@ cy.eyesCheckWindow({lazyLoad: {
|
|
|
761
768
|
}})
|
|
762
769
|
```
|
|
763
770
|
|
|
771
|
+
##### Density metrics (`densityMetrics`)
|
|
772
|
+
|
|
773
|
+
In order to set the density metrics for the screenshot, use the `densityMetrics` method. This method accepts a object value with the following properties:
|
|
774
|
+
|
|
775
|
+
- `xdpi` - The exact physical pixels per inch of the screen in the X dimension.
|
|
776
|
+
- `ydpi` - The exact physical pixels per inch of the screen in the Y dimension.
|
|
777
|
+
- `scaleRatio` - The scale ratio.
|
|
778
|
+
|
|
779
|
+
```js
|
|
780
|
+
// set density metrics
|
|
781
|
+
cy.eyesCheckWindow({
|
|
782
|
+
densityMetrics:
|
|
783
|
+
xdpi: 100,
|
|
784
|
+
ydpi: 100,
|
|
785
|
+
scaleRatio: 1
|
|
786
|
+
})
|
|
787
|
+
```
|
|
764
788
|
|
|
765
789
|
#### Close
|
|
766
790
|
|
package/dist/plugin/hooks.js
CHANGED
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const handleTestResults_1 = __importDefault(require("./handleTestResults"));
|
|
7
|
-
function makeGlobalRunHooks({ closeManager, closeBatches, closeUniversalServer }) {
|
|
7
|
+
function makeGlobalRunHooks({ closeManager, closeBatches, closeUniversalServer, }) {
|
|
8
8
|
return {
|
|
9
9
|
'before:run': ({ config }) => {
|
|
10
10
|
if (!config.isTextTerminal)
|
|
@@ -17,18 +17,18 @@ function makeGlobalRunHooks({ closeManager, closeBatches, closeUniversalServer }
|
|
|
17
17
|
const summaries = await closeManager();
|
|
18
18
|
let testResults;
|
|
19
19
|
for (const summary of summaries) {
|
|
20
|
-
testResults = summary.results.map(({
|
|
20
|
+
testResults = summary.results.map(({ result }) => result);
|
|
21
21
|
}
|
|
22
22
|
if (!config.appliConfFile.dontCloseBatches) {
|
|
23
23
|
await closeBatches({
|
|
24
|
-
|
|
24
|
+
batchId: config.appliConfFile.batchId || config.appliConfFile.batch.id,
|
|
25
25
|
serverUrl: config.appliConfFile.serverUrl,
|
|
26
26
|
proxy: config.appliConfFile.proxy,
|
|
27
27
|
apiKey: config.appliConfFile.apiKey,
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
30
|
if (config.appliConfFile.tapDirPath) {
|
|
31
|
-
|
|
31
|
+
handleTestResults_1.default.handleBatchResultsFile(testResults, {
|
|
32
32
|
tapDirPath: config.appliConfFile.tapDirPath,
|
|
33
33
|
tapFileName: config.appliConfFile.tapFileName,
|
|
34
34
|
});
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const isGlobalHooksSupported_1 = __importDefault(require("./isGlobalHooksSupported"));
|
|
7
7
|
const functional_commons_1 = require("@applitools/functional-commons");
|
|
8
8
|
const hooks_1 = __importDefault(require("./hooks"));
|
|
9
|
-
function makePluginExport({ startServer, eyesConfig }) {
|
|
9
|
+
function makePluginExport({ startServer, eyesConfig, }) {
|
|
10
10
|
return function pluginExport(pluginInitArgs) {
|
|
11
11
|
let eyesServer, pluginModuleExports, pluginExportsE2E, pluginExportsComponent;
|
|
12
12
|
let pluginExports;
|
|
@@ -55,10 +55,10 @@ function makePluginExport({ startServer, eyesConfig }) {
|
|
|
55
55
|
return pluginInitArgs;
|
|
56
56
|
}
|
|
57
57
|
return function getCloseServer() {
|
|
58
|
-
return eyesServer.close();
|
|
58
|
+
return new Promise(res => eyesServer.close(() => res()));
|
|
59
59
|
};
|
|
60
60
|
async function setupNodeEvents(origOn, cypressConfig) {
|
|
61
|
-
const { server, port, closeManager, closeBatches, closeUniversalServer } = await startServer();
|
|
61
|
+
const { server, port, closeManager, closeBatches, closeUniversalServer } = await startServer(cypressConfig);
|
|
62
62
|
eyesServer = server;
|
|
63
63
|
const globalHooks = (0, hooks_1.default)({
|
|
64
64
|
closeManager,
|
package/dist/plugin/server.js
CHANGED
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const webSocket_1 = __importDefault(require("./webSocket"));
|
|
7
|
-
const
|
|
7
|
+
const core_1 = require("@applitools/core");
|
|
8
8
|
const handleTestResults_1 = __importDefault(require("./handleTestResults"));
|
|
9
9
|
const path_1 = __importDefault(require("path"));
|
|
10
10
|
const fs_1 = __importDefault(require("fs"));
|
|
@@ -14,7 +14,7 @@ const ws_1 = require("ws");
|
|
|
14
14
|
const which_1 = __importDefault(require("which"));
|
|
15
15
|
const util_1 = require("util");
|
|
16
16
|
function makeStartServer({ logger }) {
|
|
17
|
-
return async function startServer() {
|
|
17
|
+
return async function startServer(options) {
|
|
18
18
|
const key = fs_1.default.readFileSync(path_1.default.resolve(__dirname, '../../src/pem/server.key'));
|
|
19
19
|
const cert = fs_1.default.readFileSync(path_1.default.resolve(__dirname, '../../src/pem/server.cert'));
|
|
20
20
|
const https = new https_1.Server({
|
|
@@ -29,10 +29,12 @@ function makeStartServer({ logger }) {
|
|
|
29
29
|
detached: true,
|
|
30
30
|
};
|
|
31
31
|
const cypressVersion = require('cypress/package.json').version;
|
|
32
|
-
|
|
32
|
+
const isCypressVersionBelow7 = (0, semver_1.lt)(cypressVersion, '7.0.0');
|
|
33
|
+
const isNodeVersionSystem = !!(options === null || options === void 0 ? void 0 : options.nodeVersion) && options.nodeVersion !== 'system';
|
|
34
|
+
if (isCypressVersionBelow7 || isNodeVersionSystem) {
|
|
33
35
|
forkOptions.execPath = await (0, which_1.default)('node');
|
|
34
36
|
}
|
|
35
|
-
const { port: universalPort, close: closeUniversalServer } = await (0,
|
|
37
|
+
const { port: universalPort, close: closeUniversalServer } = await (0, core_1.makeCoreServerProcess)({
|
|
36
38
|
idleTimeout: 0,
|
|
37
39
|
shutdownMode: 'stdin',
|
|
38
40
|
forkOptions,
|
|
@@ -101,14 +103,11 @@ function makeStartServer({ logger }) {
|
|
|
101
103
|
closeUniversalServer,
|
|
102
104
|
};
|
|
103
105
|
function closeManager() {
|
|
104
|
-
return Promise.all(managers.map(({ manager, socketWithUniversal }) => socketWithUniversal.request('EyesManager.
|
|
105
|
-
manager,
|
|
106
|
-
throwErr: false,
|
|
107
|
-
})));
|
|
106
|
+
return Promise.all(managers.map(({ manager, socketWithUniversal }) => socketWithUniversal.request('EyesManager.getResults', { manager, settings: { throwErr: false } })));
|
|
108
107
|
}
|
|
109
108
|
function closeBatches(settings) {
|
|
110
109
|
if (socketWithUniversal)
|
|
111
|
-
return socketWithUniversal.request('Core.
|
|
110
|
+
return socketWithUniversal.request('Core.closeBatch', { settings }).catch((err) => {
|
|
112
111
|
logger.log('@@@', err);
|
|
113
112
|
});
|
|
114
113
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applitools/eyes-cypress",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.30.1",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git://github.com/applitools/eyes.sdk.javascript1.git",
|
|
@@ -36,6 +36,8 @@
|
|
|
36
36
|
"test:ts": "yarn test:ts:compile && yarn test:ts:run",
|
|
37
37
|
"test:ts:compile": "tsc --project test/e2e/ts/cypress",
|
|
38
38
|
"test:ts:run:legacy": "yarn cypress9 run --config-file ./test/e2e/ts/cypress-ts-legacy.json",
|
|
39
|
+
"cypress8": "./node_modules/cypress8/bin/cypress",
|
|
40
|
+
"test:ts:run:8": "yarn cypress8 run --project ./test/e2e/ts --config-file ./cypress-8.config.ts",
|
|
39
41
|
"cypress9": "./node_modules/cypress9/bin/cypress",
|
|
40
42
|
"test:ts:run:9": "yarn cypress9 run --project ./test/e2e/ts --config-file ./cypress-9.config.ts",
|
|
41
43
|
"cypress10": "./node_modules/cypress10/bin/cypress",
|
|
@@ -45,7 +47,7 @@
|
|
|
45
47
|
"cypress12": "./node_modules/cypress12/bin/cypress",
|
|
46
48
|
"test:ts:run:12": "yarn cypress12 run --project ./test/e2e/ts --config-file ./cypress-12.config.ts",
|
|
47
49
|
"test:ts:run": "yarn test:ts:run:legacy && yarn test:ts:run:9",
|
|
48
|
-
"test:coverage": "yarn generate:tests && cd test/coverage/generic && yarn &&
|
|
50
|
+
"test:coverage": "yarn generate:tests && cd test/coverage/generic && yarn && APPLITOOLS_BATCH_NAME='JS Coverage Tests: eyes-cypress' APPLITOOLS_BATCH_ID=$(uuidgen) npx cypress run",
|
|
49
51
|
"test:e2e": "mkdir -p test/fixtures/testAppCopies && mocha --no-timeouts 'test/e2e/**/*.test.js'",
|
|
50
52
|
"test:components": "cd test/components && yarn && npx cypress run --component",
|
|
51
53
|
"cypress": "cypress open --config-file test/fixtures/cypress-play.json",
|
|
@@ -54,11 +56,12 @@
|
|
|
54
56
|
"cypress:run:new": "cd test/play && yarn && npx cypress run --spec=../fixtures/testApp/cypress/integration-play/play.js",
|
|
55
57
|
"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",
|
|
56
58
|
"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",
|
|
57
|
-
"
|
|
59
|
+
"setup": "yarn xvfb:setup",
|
|
60
|
+
"xvfb:setup": "sudo apt-get install -y xvfb; Xvfb -ac $DISPLAY -screen 0 1280x1024x16 & echo 'Run xvfb'; sleep 10",
|
|
58
61
|
"deps": "bongo deps",
|
|
59
62
|
"preversion": "yarn build && bongo preversion --skip-deps --verifyPendingChanges --skipVerifyInstalledVersions",
|
|
60
63
|
"version": "bongo version --withPendingChanges",
|
|
61
|
-
"postversion": "bongo postversion
|
|
64
|
+
"postversion": "bongo postversion"
|
|
62
65
|
},
|
|
63
66
|
"husky": {
|
|
64
67
|
"hooks": {
|
|
@@ -66,12 +69,11 @@
|
|
|
66
69
|
}
|
|
67
70
|
},
|
|
68
71
|
"dependencies": {
|
|
69
|
-
"@applitools/core": "
|
|
70
|
-
"@applitools/eyes-api": "1.13.
|
|
71
|
-
"@applitools/eyes-universal": "2.18.0",
|
|
72
|
+
"@applitools/core": "2.4.3",
|
|
73
|
+
"@applitools/eyes-api": "1.13.12",
|
|
72
74
|
"@applitools/functional-commons": "1.6.0",
|
|
73
|
-
"@applitools/logger": "1.1.
|
|
74
|
-
"@applitools/utils": "1.3.
|
|
75
|
+
"@applitools/logger": "1.1.48",
|
|
76
|
+
"@applitools/utils": "1.3.32",
|
|
75
77
|
"boxen": "5.1.2",
|
|
76
78
|
"chalk": "3.0.0",
|
|
77
79
|
"semver": "7.3.8",
|
|
@@ -80,20 +82,17 @@
|
|
|
80
82
|
"ws": "8.5.0"
|
|
81
83
|
},
|
|
82
84
|
"devDependencies": {
|
|
83
|
-
"@applitools/api-extractor": "^1.2.
|
|
84
|
-
"@applitools/bongo": "^
|
|
85
|
-
"@applitools/
|
|
86
|
-
"@applitools/sdk-coverage-tests": "^2.7.8",
|
|
85
|
+
"@applitools/api-extractor": "^1.2.12",
|
|
86
|
+
"@applitools/bongo": "^3.0.2",
|
|
87
|
+
"@applitools/sdk-coverage-tests": "^3.0.0",
|
|
87
88
|
"@applitools/snaptdout": "1.0.1",
|
|
88
|
-
"@applitools/test-server": "1.1.
|
|
89
|
-
"@applitools/test-utils": "1.5.
|
|
89
|
+
"@applitools/test-server": "1.1.28",
|
|
90
|
+
"@applitools/test-utils": "1.5.14",
|
|
90
91
|
"@types/node": "12",
|
|
91
92
|
"@types/semver": "^7.3.13",
|
|
92
93
|
"@types/uuid": "^9.0.0",
|
|
93
94
|
"@types/which": "^2.0.1",
|
|
94
95
|
"@types/ws": "^8.2.2",
|
|
95
|
-
"@typescript-eslint/eslint-plugin": "^5.47.1",
|
|
96
|
-
"@typescript-eslint/parser": "^5.47.1",
|
|
97
96
|
"chai": "4.2.0",
|
|
98
97
|
"chai-spies": "1.0.0",
|
|
99
98
|
"cookie-parser": "1.4.4",
|
|
@@ -101,13 +100,10 @@
|
|
|
101
100
|
"cypress10": "npm:cypress@^10.0.0",
|
|
102
101
|
"cypress11": "npm:cypress@^11.0.0",
|
|
103
102
|
"cypress12": "npm:cypress@^12.0.0",
|
|
103
|
+
"cypress8": "npm:cypress@^8.7.0",
|
|
104
104
|
"cypress9": "npm:cypress@^9.0.0",
|
|
105
105
|
"eslint": "8.10.0",
|
|
106
|
-
"eslint-
|
|
107
|
-
"eslint-plugin-mocha-no-only": "1.1.0",
|
|
108
|
-
"eslint-plugin-no-only-tests": "^3.1.0",
|
|
109
|
-
"eslint-plugin-node": "^11.1.0",
|
|
110
|
-
"eslint-plugin-prettier": "^4.0.0",
|
|
106
|
+
"eslint-plugin-mocha-no-only": "1.1.1",
|
|
111
107
|
"husky": "4.3.8",
|
|
112
108
|
"lodash.omit": "4.5.0",
|
|
113
109
|
"mocha": "8.0.1",
|
package/src/browser/commands.js
CHANGED
|
@@ -4,18 +4,31 @@ const spec = require('../../dist/browser/spec-driver')
|
|
|
4
4
|
const Refer = require('./refer')
|
|
5
5
|
const Socket = require('./socket')
|
|
6
6
|
const {socketCommands} = require('./socketCommands')
|
|
7
|
-
const {eyesOpenMapValues} = require('./eyesOpenMapping')
|
|
7
|
+
const {eyesOpenMapValues, eyesOpenToCheckMapValues} = require('./eyesOpenMapping')
|
|
8
8
|
const {eyesCheckMapValues} = require('./eyesCheckMapping')
|
|
9
9
|
const {TestResultsSummary} = require('@applitools/eyes-api')
|
|
10
10
|
const refer = new Refer()
|
|
11
11
|
const socket = new Socket()
|
|
12
12
|
const throwErr = Cypress.config('failCypressOnDiff')
|
|
13
13
|
socketCommands(socket, refer)
|
|
14
|
-
let connectedToUniversal = false
|
|
15
14
|
|
|
16
15
|
let manager,
|
|
17
16
|
eyes,
|
|
18
|
-
closePromiseArr = []
|
|
17
|
+
closePromiseArr = [],
|
|
18
|
+
_summary,
|
|
19
|
+
connectedToUniversal,
|
|
20
|
+
openToCheckSettingsArgs
|
|
21
|
+
|
|
22
|
+
async function getSummary() {
|
|
23
|
+
if (_summary) return _summary
|
|
24
|
+
await Promise.all(closePromiseArr)
|
|
25
|
+
_summary = socket.request('EyesManager.getResults', {manager, settings: {throwErr}}).catch(err => {
|
|
26
|
+
return {results: [{result: err.info.result}]}
|
|
27
|
+
})
|
|
28
|
+
_summary = await _summary
|
|
29
|
+
|
|
30
|
+
return _summary
|
|
31
|
+
}
|
|
19
32
|
|
|
20
33
|
function getGlobalConfigProperty(prop) {
|
|
21
34
|
const property = Cypress.config(prop)
|
|
@@ -34,8 +47,6 @@ Cypress.Commands.add('eyesGetAllTestResults', () => {
|
|
|
34
47
|
isCurrentTestDisabled = false
|
|
35
48
|
return
|
|
36
49
|
}
|
|
37
|
-
await Promise.all(closePromiseArr)
|
|
38
|
-
const summary = await socket.request('EyesManager.closeManager', {manager, throwErr})
|
|
39
50
|
|
|
40
51
|
const deleteTest = ({settings: {testId, batchId, secretToken}}) => {
|
|
41
52
|
const {serverUrl, proxy, apiKey} = Cypress.config('appliConfFile')
|
|
@@ -50,9 +61,7 @@ Cypress.Commands.add('eyesGetAllTestResults', () => {
|
|
|
50
61
|
},
|
|
51
62
|
})
|
|
52
63
|
}
|
|
53
|
-
summary
|
|
54
|
-
return {...res, result: res.testResults, error: res.exception, renderer: res.browserInfo}
|
|
55
|
-
})
|
|
64
|
+
const summary = await getSummary()
|
|
56
65
|
return new TestResultsSummary({summary, deleteTest})
|
|
57
66
|
})
|
|
58
67
|
})
|
|
@@ -73,9 +82,9 @@ if (shouldUseBrowserHooks || Cypress.config('eyesFailCypressOnDiff')) {
|
|
|
73
82
|
tapFileName: Cypress.config('appliConfFile').tapFileName,
|
|
74
83
|
shouldCreateTapFile: shouldUseBrowserHooks,
|
|
75
84
|
}
|
|
76
|
-
|
|
77
|
-
const summary = await
|
|
78
|
-
const testResults = summary.results.map(({
|
|
85
|
+
|
|
86
|
+
const summary = await getSummary()
|
|
87
|
+
const testResults = summary.results.map(({result}) => result)
|
|
79
88
|
const message = await socket.request('Test.printTestResults', {testResults, resultConfig})
|
|
80
89
|
if (
|
|
81
90
|
!!getGlobalConfigProperty('eyesFailCypressOnDiff') &&
|
|
@@ -105,38 +114,37 @@ Cypress.Commands.add('eyesOpen', function (args = {}) {
|
|
|
105
114
|
|
|
106
115
|
return cy.then({timeout: 86400000}, async () => {
|
|
107
116
|
setRootContext()
|
|
108
|
-
const
|
|
117
|
+
const target = refer.ref(cy.state('window').document)
|
|
109
118
|
|
|
110
119
|
if (!connectedToUniversal) {
|
|
111
120
|
socket.connect(`wss://localhost:${Cypress.config('eyesPort')}/eyes`)
|
|
112
121
|
connectedToUniversal = true
|
|
113
|
-
socket.emit('Core.
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
122
|
+
socket.emit('Core.makeCore', {
|
|
123
|
+
agentId: `eyes.cypress/${require('../../package.json').version}`,
|
|
124
|
+
cwd: Cypress.config('projectRoot'),
|
|
125
|
+
spec: Object.keys(spec).concat(['isSelector', 'isDriver', 'isElement']), // TODO fix spec.isSelector and spec.isDriver and spec.isElement in driver
|
|
117
126
|
})
|
|
118
127
|
|
|
119
128
|
manager =
|
|
120
129
|
manager ||
|
|
121
130
|
(await socket.request(
|
|
122
131
|
'Core.makeManager',
|
|
123
|
-
Object.assign({}, {concurrency: Cypress.config('eyesTestConcurrency')}, {
|
|
132
|
+
Object.assign({}, {concurrency: Cypress.config('eyesTestConcurrency')}, {type: 'ufg'}),
|
|
124
133
|
))
|
|
125
134
|
}
|
|
126
135
|
|
|
127
136
|
const appliConfFile = Cypress.config('appliConfFile')
|
|
128
|
-
|
|
137
|
+
|
|
138
|
+
openToCheckSettingsArgs = eyesOpenToCheckMapValues(args)
|
|
139
|
+
|
|
140
|
+
const settings = eyesOpenMapValues({
|
|
129
141
|
args,
|
|
130
142
|
appliConfFile,
|
|
131
143
|
testName,
|
|
132
144
|
shouldUseBrowserHooks,
|
|
133
|
-
defaultBrowser: {
|
|
134
|
-
width: Cypress.config('viewportWidth'),
|
|
135
|
-
height: Cypress.config('viewportHeight'),
|
|
136
|
-
name: 'chrome',
|
|
137
|
-
},
|
|
138
145
|
})
|
|
139
|
-
|
|
146
|
+
|
|
147
|
+
eyes = await socket.request('EyesManager.openEyes', {manager, target, settings})
|
|
140
148
|
})
|
|
141
149
|
})
|
|
142
150
|
|
|
@@ -145,16 +153,20 @@ Cypress.Commands.add('eyesCheckWindow', (args = {}) =>
|
|
|
145
153
|
if (isCurrentTestDisabled) return
|
|
146
154
|
|
|
147
155
|
setRootContext()
|
|
148
|
-
const
|
|
156
|
+
const target = refer.ref(cy.state('window').document)
|
|
149
157
|
|
|
150
158
|
Cypress.log({name: 'Eyes: check window'})
|
|
151
159
|
|
|
152
|
-
const
|
|
160
|
+
const settings = eyesCheckMapValues({
|
|
161
|
+
args: {...openToCheckSettingsArgs, ...args},
|
|
162
|
+
refer,
|
|
163
|
+
appliConfFile: Cypress.config('appliConfFile'),
|
|
164
|
+
})
|
|
153
165
|
|
|
154
166
|
return socket.request('Eyes.check', {
|
|
155
167
|
eyes,
|
|
156
|
-
settings
|
|
157
|
-
|
|
168
|
+
settings,
|
|
169
|
+
target,
|
|
158
170
|
})
|
|
159
171
|
}),
|
|
160
172
|
)
|
|
@@ -169,11 +181,12 @@ Cypress.Commands.add('eyesClose', () => {
|
|
|
169
181
|
return
|
|
170
182
|
}
|
|
171
183
|
|
|
172
|
-
//
|
|
173
|
-
const p = socket.request('Eyes.close', {eyes
|
|
184
|
+
// Eyes.close in core is not waiting on results anymore. So we should return it in order to await it
|
|
185
|
+
const p = socket.request('Eyes.close', {eyes}).catch(err => {
|
|
174
186
|
console.log('Error in cy.eyesClose', err)
|
|
175
187
|
})
|
|
176
188
|
closePromiseArr.push(p)
|
|
189
|
+
return p
|
|
177
190
|
})
|
|
178
191
|
})
|
|
179
192
|
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
/* global Node */
|
|
2
|
-
function eyesCheckMapValues({args, refer}) {
|
|
2
|
+
function eyesCheckMapValues({openToCheckSettingsArgs, args, refer, appliConfFile}) {
|
|
3
3
|
if (typeof args === `string`) {
|
|
4
4
|
args = {tag: args}
|
|
5
5
|
}
|
|
6
|
-
|
|
6
|
+
args = {...openToCheckSettingsArgs, ...args}
|
|
7
|
+
if (typeof args.waitBeforeCapture !== 'number') args.waitBeforeCapture = appliConfFile.waitBeforeCapture
|
|
8
|
+
let accessibilitySettings = args.accessibilitySettings || appliConfFile.accessibilityValidation
|
|
9
|
+
|
|
7
10
|
const mappedValues = [
|
|
8
11
|
'tag',
|
|
9
12
|
'scriptHooks',
|
|
@@ -20,56 +23,75 @@ function eyesCheckMapValues({args, refer}) {
|
|
|
20
23
|
|
|
21
24
|
let regionSettings = {}
|
|
22
25
|
let shadowDomSettings = {}
|
|
26
|
+
|
|
27
|
+
let renderers = args.renderers || args.browser || appliConfFile.browser
|
|
28
|
+
if (renderers) {
|
|
29
|
+
if (Array.isArray(renderers)) {
|
|
30
|
+
for (const [index, value] of renderers.entries()) {
|
|
31
|
+
renderers[index] = fillDefaultBrowserName(value)
|
|
32
|
+
}
|
|
33
|
+
} else {
|
|
34
|
+
renderers = [fillDefaultBrowserName(renderers)]
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
23
38
|
const checkSettings = {
|
|
24
|
-
name:
|
|
25
|
-
hooks:
|
|
26
|
-
ignoreRegions: convertPaddedRegion(
|
|
27
|
-
floatingRegions: convertFloatingRegion(
|
|
28
|
-
strictRegions: convertPaddedRegion(
|
|
29
|
-
layoutRegions: convertPaddedRegion(
|
|
30
|
-
contentRegions: convertPaddedRegion(
|
|
31
|
-
accessibilityRegions: convertAccessabilityRegions(
|
|
39
|
+
name: args.tag,
|
|
40
|
+
hooks: args.scriptHooks,
|
|
41
|
+
ignoreRegions: convertPaddedRegion(args.ignore),
|
|
42
|
+
floatingRegions: convertFloatingRegion(args.floating),
|
|
43
|
+
strictRegions: convertPaddedRegion(args.strict),
|
|
44
|
+
layoutRegions: convertPaddedRegion(args.layout),
|
|
45
|
+
contentRegions: convertPaddedRegion(args.content),
|
|
46
|
+
accessibilityRegions: convertAccessabilityRegions(args.accessibility),
|
|
47
|
+
renderers,
|
|
48
|
+
}
|
|
49
|
+
if (args.variationGroupId) {
|
|
50
|
+
checkSettings.userCommandId = args.variationGroupId
|
|
51
|
+
}
|
|
52
|
+
if (args.accessibilitySettings) {
|
|
53
|
+
checkSettings.accessibilitySettings = accessibilitySettings
|
|
32
54
|
}
|
|
33
55
|
|
|
34
|
-
if (
|
|
35
|
-
if (!Array.isArray(
|
|
36
|
-
if (
|
|
37
|
-
if (isHTMLElement(
|
|
56
|
+
if (args.target === 'region') {
|
|
57
|
+
if (!Array.isArray(args.selector)) {
|
|
58
|
+
if (args.element) {
|
|
59
|
+
if (isHTMLElement(args.element)) {
|
|
38
60
|
regionSettings = {
|
|
39
|
-
region: Object.assign(refer.ref(
|
|
61
|
+
region: Object.assign(refer.ref(args.element), {type: 'element'}),
|
|
40
62
|
}
|
|
41
63
|
} else {
|
|
42
64
|
// JQuery element
|
|
43
65
|
regionSettings = {
|
|
44
|
-
region: Object.assign(refer.ref(
|
|
66
|
+
region: Object.assign(refer.ref(args.element[0]), {type: 'element'}),
|
|
45
67
|
}
|
|
46
68
|
}
|
|
47
69
|
} else if (
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
70
|
+
args.region &&
|
|
71
|
+
args.region.hasOwnProperty('top') &&
|
|
72
|
+
args.region.hasOwnProperty('left') &&
|
|
73
|
+
args.region.hasOwnProperty('width') &&
|
|
74
|
+
args.region.hasOwnProperty('height')
|
|
53
75
|
) {
|
|
54
76
|
regionSettings = {
|
|
55
77
|
region: {
|
|
56
|
-
y:
|
|
57
|
-
x:
|
|
58
|
-
width:
|
|
59
|
-
height:
|
|
78
|
+
y: args.region.top,
|
|
79
|
+
x: args.region.left,
|
|
80
|
+
width: args.region.width,
|
|
81
|
+
height: args.region.height,
|
|
60
82
|
},
|
|
61
83
|
}
|
|
62
|
-
} else if (!
|
|
84
|
+
} else if (!args.hasOwnProperty('selector')) {
|
|
63
85
|
regionSettings = {
|
|
64
|
-
region:
|
|
86
|
+
region: args.region,
|
|
65
87
|
}
|
|
66
88
|
} else {
|
|
67
89
|
regionSettings = {
|
|
68
|
-
region:
|
|
90
|
+
region: args.selector,
|
|
69
91
|
}
|
|
70
92
|
}
|
|
71
93
|
} else {
|
|
72
|
-
const selectors =
|
|
94
|
+
const selectors = args.selector
|
|
73
95
|
for (let i = selectors.length - 1; i > -1; i--) {
|
|
74
96
|
if (i === selectors.length - 1) {
|
|
75
97
|
shadowDomSettings['shadow'] = selectors[i].selector
|
|
@@ -88,12 +110,12 @@ function eyesCheckMapValues({args, refer}) {
|
|
|
88
110
|
}
|
|
89
111
|
|
|
90
112
|
for (const val of mappedValues) {
|
|
91
|
-
if (
|
|
92
|
-
delete
|
|
113
|
+
if (args.hasOwnProperty(val)) {
|
|
114
|
+
delete args[val]
|
|
93
115
|
}
|
|
94
116
|
}
|
|
95
117
|
|
|
96
|
-
return Object.assign({}, checkSettings, regionSettings,
|
|
118
|
+
return Object.assign({}, checkSettings, regionSettings, args)
|
|
97
119
|
|
|
98
120
|
// #region helper functions
|
|
99
121
|
|
|
@@ -176,10 +198,12 @@ function eyesCheckMapValues({args, refer}) {
|
|
|
176
198
|
|
|
177
199
|
for (const region of floatingRegions) {
|
|
178
200
|
const floatingRegion = {
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
201
|
+
offset: {
|
|
202
|
+
bottom: region.maxDownOffset || 0,
|
|
203
|
+
left: region.maxLeftOffset || 0,
|
|
204
|
+
top: region.maxUpOffset || 0,
|
|
205
|
+
right: region.maxRightOffset || 0,
|
|
206
|
+
},
|
|
183
207
|
}
|
|
184
208
|
if (region.hasOwnProperty('selector')) {
|
|
185
209
|
floatingRegion.region = region.selector
|
|
@@ -191,7 +215,7 @@ function eyesCheckMapValues({args, refer}) {
|
|
|
191
215
|
floating.push(Object.assign({}, region, floatingRegion, {region: element}))
|
|
192
216
|
}
|
|
193
217
|
} else if (region.hasOwnProperty('region')) {
|
|
194
|
-
floating.push(region)
|
|
218
|
+
floating.push({offset: floatingRegion.offset, ...region})
|
|
195
219
|
} else {
|
|
196
220
|
floatingRegion.region = {
|
|
197
221
|
y: region.top,
|
|
@@ -233,4 +257,18 @@ function isHTMLElement(element) {
|
|
|
233
257
|
return element.nodeType && element.nodeType === Node.ELEMENT_NODE
|
|
234
258
|
}
|
|
235
259
|
|
|
260
|
+
function fillDefaultBrowserName(browser) {
|
|
261
|
+
if (!browser.iosDeviceInfo && !browser.chromeEmulationInfo) {
|
|
262
|
+
if (!browser.name) {
|
|
263
|
+
browser.name = 'chrome'
|
|
264
|
+
}
|
|
265
|
+
if (browser.deviceName) {
|
|
266
|
+
browser = {chromeEmulationInfo: browser}
|
|
267
|
+
}
|
|
268
|
+
return browser
|
|
269
|
+
} else {
|
|
270
|
+
return browser
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
236
274
|
module.exports = {eyesCheckMapValues}
|