@applitools/eyes-cypress 3.22.3 → 3.22.7
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 +24 -0
- package/README.md +19 -0
- package/package.json +9 -7
- package/src/browser/commands.js +1 -1
- package/src/plugin/config.js +0 -1
- package/src/plugin/hooks.js +27 -29
- package/src/plugin/pluginExport.js +24 -8
- package/src/plugin/runningTests.js +3 -1
- package/src/plugin/startPlugin.js +8 -6
- package/test/fixtures/testAppCopies/.gitignore +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,30 @@
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
5
|
|
|
6
|
+
## 3.22.7 - 2021/11/7
|
|
7
|
+
|
|
8
|
+
- replace legacy logger construction with new
|
|
9
|
+
- Support running user defined run hooks in Cypress
|
|
10
|
+
- Fix cypress tests not being cleaned up
|
|
11
|
+
- Fix duplicate batch start/end events in cypress
|
|
12
|
+
- updated to @applitools/dom-snapshot@4.5.10 (from 4.5.9)
|
|
13
|
+
- updated to @applitools/visual-grid-client@15.8.43 (from 15.8.36)
|
|
14
|
+
|
|
15
|
+
## 3.22.6 - 2021/10/18
|
|
16
|
+
|
|
17
|
+
- updated to @applitools/dom-snapshot@4.5.9 (from 4.5.8)
|
|
18
|
+
- updated to @applitools/visual-grid-client@15.8.36 (from 15.8.31)
|
|
19
|
+
|
|
20
|
+
## 3.22.5 - 2021/9/29
|
|
21
|
+
|
|
22
|
+
- fix layout-breakpoints should not hit cypress timeout
|
|
23
|
+
- updated to @applitools/dom-snapshot@4.5.8 (from 4.5.7)
|
|
24
|
+
- updated to @applitools/visual-grid-client@15.8.31 (from 15.8.24)
|
|
25
|
+
|
|
26
|
+
## 3.22.4 - 2021/9/7
|
|
27
|
+
|
|
28
|
+
- Update README to include an example about region within shadow DOM
|
|
29
|
+
- updated to @applitools/visual-grid-client@15.8.24 (from 15.8.21)
|
|
6
30
|
|
|
7
31
|
## 3.22.3 - 2021/8/16
|
|
8
32
|
|
package/README.md
CHANGED
|
@@ -187,6 +187,7 @@ Applitools will take screenshots and perform the visual comparisons in the backg
|
|
|
187
187
|
- [strict](#strict)
|
|
188
188
|
- [content](#content)
|
|
189
189
|
- [accessibility](#accessibility)
|
|
190
|
+
- [region in shadow DOM](#region-in-shadow-dom)
|
|
190
191
|
- [scriptHooks](#scriptHooks)
|
|
191
192
|
- [layoutBreakpoints](#layoutBreakpoints)
|
|
192
193
|
- [sendDom](#sendDom)
|
|
@@ -387,6 +388,24 @@ cy.eyesCheckWindow({
|
|
|
387
388
|
|
|
388
389
|
Possible accessibilityType values are: `IgnoreContrast`,`RegularText`,`LargeText`,`BoldText` and `GraphicalObject`.
|
|
389
390
|
|
|
391
|
+
##### `region in shadow DOM`
|
|
392
|
+
|
|
393
|
+
When the target region is within shadow DOM, there is a need to specify the path to that region by passing an array of selectors. Each entry in the array should contain a `json` with the following entries: `type:css` ***only***, `selector` and `nodeType`. The element that contains the `shadowRoot` should be specified as `nodeType:'shadow-root'` and the final target region should contain `nodeType:'element'`
|
|
394
|
+
|
|
395
|
+
```js
|
|
396
|
+
cy.eyesCheckWindow({
|
|
397
|
+
target: 'region',
|
|
398
|
+
selector: [{
|
|
399
|
+
type: 'css',
|
|
400
|
+
selector: 'ContainShadowRoot' ,
|
|
401
|
+
nodeType: 'shadow-root'
|
|
402
|
+
},{
|
|
403
|
+
type: 'css',
|
|
404
|
+
selector: 'targetRegion',
|
|
405
|
+
nodeType: 'element'
|
|
406
|
+
}]
|
|
407
|
+
});
|
|
408
|
+
```
|
|
390
409
|
##### `scriptHooks`
|
|
391
410
|
|
|
392
411
|
(optional): A set of scripts to be run by the browser during the rendering. It is intended to be used as a means to alter the page's state and structure at the time of rendering.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@applitools/eyes-cypress",
|
|
3
|
-
"version": "3.22.
|
|
3
|
+
"version": "3.22.7",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"bin": {
|
|
@@ -35,12 +35,14 @@
|
|
|
35
35
|
},
|
|
36
36
|
"repository": {
|
|
37
37
|
"type": "git",
|
|
38
|
-
"url": "git://github.com/applitools/eyes.sdk.javascript1.git"
|
|
38
|
+
"url": "git://github.com/applitools/eyes.sdk.javascript1.git",
|
|
39
|
+
"directory": "packages/eyes-cypress"
|
|
39
40
|
},
|
|
40
41
|
"dependencies": {
|
|
41
|
-
"@applitools/dom-snapshot": "4.5.
|
|
42
|
+
"@applitools/dom-snapshot": "4.5.10",
|
|
42
43
|
"@applitools/functional-commons": "1.6.0",
|
|
43
|
-
"@applitools/
|
|
44
|
+
"@applitools/logger": "1.0.5",
|
|
45
|
+
"@applitools/visual-grid-client": "15.8.43",
|
|
44
46
|
"body-parser": "1.19.0",
|
|
45
47
|
"chalk": "3.0.0",
|
|
46
48
|
"cors": "2.8.5",
|
|
@@ -49,10 +51,10 @@
|
|
|
49
51
|
},
|
|
50
52
|
"devDependencies": {
|
|
51
53
|
"@applitools/scripts": "^1.0.1",
|
|
52
|
-
"@applitools/sdk-release-kit": "0.13.
|
|
53
|
-
"@applitools/sdk-shared": "0.9.
|
|
54
|
+
"@applitools/sdk-release-kit": "0.13.4",
|
|
55
|
+
"@applitools/sdk-shared": "0.9.7",
|
|
54
56
|
"@applitools/snaptdout": "1.0.1",
|
|
55
|
-
"@applitools/test-server": "1.0.
|
|
57
|
+
"@applitools/test-server": "1.0.6",
|
|
56
58
|
"chai": "^4.2.0",
|
|
57
59
|
"chai-spies": "^1.0.0",
|
|
58
60
|
"cookie-parser": "^1.4.4",
|
package/src/browser/commands.js
CHANGED
|
@@ -18,7 +18,7 @@ function getGlobalConfigProperty(prop) {
|
|
|
18
18
|
const shouldParse = ['eyesBrowser', 'eyesLayoutBreakpoints'];
|
|
19
19
|
return property ? (shouldParse.includes(prop) ? JSON.parse(property) : property) : undefined;
|
|
20
20
|
}
|
|
21
|
-
if (!getGlobalConfigProperty('eyesIsDisabled') && getGlobalConfigProperty('
|
|
21
|
+
if (!getGlobalConfigProperty('eyesIsDisabled') && getGlobalConfigProperty('isInteractive')) {
|
|
22
22
|
const batchEnd = poll(() => {
|
|
23
23
|
return sendRequest({command: 'batchEnd'});
|
|
24
24
|
});
|
package/src/plugin/config.js
CHANGED
|
@@ -42,7 +42,6 @@ function makeConfig() {
|
|
|
42
42
|
eyesFailCypressOnDiff:
|
|
43
43
|
config.failCypressOnDiff === undefined ? true : !!config.failCypressOnDiff,
|
|
44
44
|
eyesDisableBrowserFetching: !!config.disableBrowserFetching,
|
|
45
|
-
eyesLegacyHooks: true,
|
|
46
45
|
eyesTestConcurrency: config.testConcurrency || DEFAULT_TEST_CONCURRENCY,
|
|
47
46
|
};
|
|
48
47
|
|
package/src/plugin/hooks.js
CHANGED
|
@@ -4,41 +4,39 @@ const makeHandleBatchResultsFile = require('./makeHandleBatchResultsFile');
|
|
|
4
4
|
const getErrorsAndDiffs = require('./getErrorsAndDiffs');
|
|
5
5
|
const processCloseAndAbort = require('./processCloseAndAbort');
|
|
6
6
|
const errorDigest = require('./errorDigest');
|
|
7
|
-
const
|
|
7
|
+
const runningTests = require('./runningTests');
|
|
8
8
|
|
|
9
|
-
function
|
|
9
|
+
function makeGlobalRunHooks({visualGridClient, logger}) {
|
|
10
10
|
let waitForBatch;
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
eyesConfig.eyesLegacyHooks = false;
|
|
12
|
+
return {
|
|
13
|
+
'before:run': ({config}) => {
|
|
14
|
+
const {isTextTerminal, eyesTestConcurrency: testConcurrency} = config;
|
|
15
|
+
if (!config.isTextTerminal) return;
|
|
17
16
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
17
|
+
waitForBatch = makeWaitForBatch({
|
|
18
|
+
logger: (logger.extend && logger.extend('waitForBatch')) || console,
|
|
19
|
+
testConcurrency,
|
|
20
|
+
processCloseAndAbort,
|
|
21
|
+
getErrorsAndDiffs,
|
|
22
|
+
errorDigest,
|
|
23
|
+
isInteractive: !isTextTerminal,
|
|
24
|
+
handleBatchResultsFile: makeHandleBatchResultsFile(config),
|
|
25
|
+
});
|
|
26
|
+
},
|
|
28
27
|
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
'after:run': async ({config}) => {
|
|
29
|
+
if (!config.isTextTerminal) return;
|
|
31
30
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
throw e;
|
|
31
|
+
try {
|
|
32
|
+
await waitForBatch(runningTests.tests, visualGridClient.closeBatch);
|
|
33
|
+
} catch (e) {
|
|
34
|
+
if (!!config.eyesFailCypressOnDiff) {
|
|
35
|
+
throw e;
|
|
36
|
+
}
|
|
39
37
|
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
38
|
+
},
|
|
39
|
+
};
|
|
42
40
|
}
|
|
43
41
|
|
|
44
|
-
module.exports =
|
|
42
|
+
module.exports = makeGlobalRunHooks;
|
|
@@ -1,22 +1,38 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
const setGlobalRunHooks = require('./hooks');
|
|
3
2
|
const shouldSetGlobalHooks = require('./shouldSetGlobalHooks');
|
|
3
|
+
const {presult} = require('@applitools/functional-commons');
|
|
4
4
|
|
|
5
|
-
function makePluginExport({startServer, eyesConfig,
|
|
5
|
+
function makePluginExport({startServer, eyesConfig, globalHooks}) {
|
|
6
6
|
return function pluginExport(pluginModule) {
|
|
7
7
|
let closeEyesServer;
|
|
8
8
|
const pluginModuleExports = pluginModule.exports;
|
|
9
9
|
pluginModule.exports = async (...args) => {
|
|
10
10
|
const {eyesPort, closeServer} = await startServer();
|
|
11
11
|
closeEyesServer = closeServer;
|
|
12
|
-
const
|
|
13
|
-
const
|
|
12
|
+
const [origOn, config] = args;
|
|
13
|
+
const moduleExportsResult = await pluginModuleExports(onThatCallsUserDefinedHandler, config);
|
|
14
|
+
return Object.assign({}, eyesConfig, {eyesPort}, moduleExportsResult);
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
// This piece of code exists because at the point of writing, Cypress does not support multiple event handlers:
|
|
17
|
+
// https://github.com/cypress-io/cypress/issues/5240#issuecomment-948277554
|
|
18
|
+
// So we wrap Cypress' `on` function in order to wrap the user-defined handler. This way we can call our own handler
|
|
19
|
+
// in addition to the user's handler
|
|
20
|
+
function onThatCallsUserDefinedHandler(eventName, handler) {
|
|
21
|
+
const isRunEvent = eventName === 'before:run' || eventName === 'after:run';
|
|
22
|
+
const handlerToCall =
|
|
23
|
+
shouldSetGlobalHooks(config) && isRunEvent ? handlerThatCallsUserDefinedHandler : handler;
|
|
24
|
+
return origOn.call(this, eventName, handlerToCall);
|
|
18
25
|
|
|
19
|
-
|
|
26
|
+
async function handlerThatCallsUserDefinedHandler() {
|
|
27
|
+
const [err] = await presult(
|
|
28
|
+
Promise.resolve(globalHooks[eventName].apply(this, arguments)),
|
|
29
|
+
);
|
|
30
|
+
await handler.apply(this, arguments);
|
|
31
|
+
if (err) {
|
|
32
|
+
throw err;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
20
36
|
};
|
|
21
37
|
return function getCloseServer() {
|
|
22
38
|
return closeEyesServer;
|
|
@@ -9,8 +9,10 @@ const runningTests = {
|
|
|
9
9
|
this.tests = [];
|
|
10
10
|
},
|
|
11
11
|
async abortTests() {
|
|
12
|
+
const tests = this.tests;
|
|
13
|
+
this.reset();
|
|
12
14
|
return Promise.all(
|
|
13
|
-
|
|
15
|
+
tests.map(async test => {
|
|
14
16
|
if (test.closePromise) {
|
|
15
17
|
// this condition doesn't really happen in the code, but it's here for purity. This is used in handlers' batchStart in order to cleanup the state in case a zombie open was called.
|
|
16
18
|
await test.closePromise;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
const {makeVisualGridClient
|
|
2
|
+
const {makeVisualGridClient} = require('@applitools/visual-grid-client');
|
|
3
|
+
const {makeLogger} = require('@applitools/logger');
|
|
3
4
|
const makeStartServer = require('./server');
|
|
4
5
|
const makePluginExport = require('./pluginExport');
|
|
5
6
|
const {startApp} = require('./app');
|
|
@@ -8,13 +9,12 @@ const processCloseAndAbort = require('./processCloseAndAbort');
|
|
|
8
9
|
const errorDigest = require('./errorDigest');
|
|
9
10
|
const makeHandlers = require('./handlers');
|
|
10
11
|
const makeConfig = require('./config');
|
|
12
|
+
const makeGlobalRunHooks = require('./hooks');
|
|
11
13
|
|
|
12
14
|
const {config, eyesConfig} = makeConfig();
|
|
13
|
-
const logger =
|
|
15
|
+
const logger = makeLogger({level: config.showLogs ? 'info' : 'silent', label: 'eyes'});
|
|
14
16
|
|
|
15
|
-
const visualGridClient = makeVisualGridClient(
|
|
16
|
-
Object.assign(config, {logger: (logger.extend && logger.extend('vgc')) || logger}),
|
|
17
|
-
);
|
|
17
|
+
const visualGridClient = makeVisualGridClient({...config, logger: logger.extend('vgc')});
|
|
18
18
|
|
|
19
19
|
const handlers = makeHandlers({
|
|
20
20
|
logger,
|
|
@@ -25,8 +25,10 @@ const handlers = makeHandlers({
|
|
|
25
25
|
errorDigest,
|
|
26
26
|
});
|
|
27
27
|
|
|
28
|
+
const globalHooks = makeGlobalRunHooks({visualGridClient, logger});
|
|
29
|
+
|
|
28
30
|
const app = startApp({handlers, logger});
|
|
29
31
|
const startServer = makeStartServer({app, logger});
|
|
30
32
|
logger.log('eyes-cypress plugin running with config:', config);
|
|
31
33
|
|
|
32
|
-
module.exports = makePluginExport({startServer, eyesConfig,
|
|
34
|
+
module.exports = makePluginExport({startServer, eyesConfig, globalHooks});
|