@applitools/eyes-cypress 3.22.7 → 3.22.8
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
|
@@ -3,6 +3,11 @@
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
5
|
|
|
6
|
+
## 3.22.8 - 2021/11/9
|
|
7
|
+
|
|
8
|
+
- fix not calling the global hooks before:run and after:run at all, unless the user also called them in his plugins file.
|
|
9
|
+
- fix not calling the browser hooks for Cypress versions < 6.2.0 (where global hooks are not supported).
|
|
10
|
+
|
|
6
11
|
## 3.22.7 - 2021/11/7
|
|
7
12
|
|
|
8
13
|
- replace legacy logger construction with new
|
package/package.json
CHANGED
package/src/browser/commands.js
CHANGED
|
@@ -18,7 +18,13 @@ function getGlobalConfigProperty(prop) {
|
|
|
18
18
|
const shouldParse = ['eyesBrowser', 'eyesLayoutBreakpoints'];
|
|
19
19
|
return property ? (shouldParse.includes(prop) ? JSON.parse(property) : property) : undefined;
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
|
|
22
|
+
const shouldUseBrowserHooks =
|
|
23
|
+
!getGlobalConfigProperty('eyesIsDisabled') &&
|
|
24
|
+
(getGlobalConfigProperty('isInteractive') ||
|
|
25
|
+
!getGlobalConfigProperty('eyesIsGlobalHooksSupported'));
|
|
26
|
+
|
|
27
|
+
if (shouldUseBrowserHooks) {
|
|
22
28
|
const batchEnd = poll(() => {
|
|
23
29
|
return sendRequest({command: 'batchEnd'});
|
|
24
30
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const CYPRESS_SUPPORTED_VERSION = '6.2.0';
|
|
2
2
|
const CYPRESS_NO_FLAG_VERSION = '6.7.0';
|
|
3
3
|
|
|
4
|
-
function
|
|
4
|
+
function isGlobalHooksSupported(config) {
|
|
5
5
|
const {version, experimentalRunEvents} = config;
|
|
6
6
|
|
|
7
7
|
return (
|
|
@@ -10,4 +10,4 @@ function shouldSetGlobalHooks(config) {
|
|
|
10
10
|
);
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
module.exports =
|
|
13
|
+
module.exports = isGlobalHooksSupported;
|
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
const
|
|
2
|
+
const isGlobalHooksSupported = require('./isGlobalHooksSupported');
|
|
3
3
|
const {presult} = require('@applitools/functional-commons');
|
|
4
4
|
|
|
5
5
|
function makePluginExport({startServer, eyesConfig, globalHooks}) {
|
|
6
6
|
return function pluginExport(pluginModule) {
|
|
7
7
|
let closeEyesServer;
|
|
8
8
|
const pluginModuleExports = pluginModule.exports;
|
|
9
|
-
pluginModule.exports = async (...args)
|
|
9
|
+
pluginModule.exports = async function(...args) {
|
|
10
10
|
const {eyesPort, closeServer} = await startServer();
|
|
11
11
|
closeEyesServer = closeServer;
|
|
12
12
|
const [origOn, config] = args;
|
|
13
|
+
let isGlobalHookCalledFromUserHandler = false;
|
|
14
|
+
eyesConfig.eyesIsGlobalHooksSupported = isGlobalHooksSupported(config);
|
|
13
15
|
const moduleExportsResult = await pluginModuleExports(onThatCallsUserDefinedHandler, config);
|
|
16
|
+
if (eyesConfig.eyesIsGlobalHooksSupported && !isGlobalHookCalledFromUserHandler) {
|
|
17
|
+
for (const [eventName, eventHandler] of Object.entries(globalHooks)) {
|
|
18
|
+
origOn.call(this, eventName, eventHandler);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
14
21
|
return Object.assign({}, eyesConfig, {eyesPort}, moduleExportsResult);
|
|
15
22
|
|
|
16
23
|
// This piece of code exists because at the point of writing, Cypress does not support multiple event handlers:
|
|
@@ -19,8 +26,11 @@ function makePluginExport({startServer, eyesConfig, globalHooks}) {
|
|
|
19
26
|
// in addition to the user's handler
|
|
20
27
|
function onThatCallsUserDefinedHandler(eventName, handler) {
|
|
21
28
|
const isRunEvent = eventName === 'before:run' || eventName === 'after:run';
|
|
22
|
-
|
|
23
|
-
|
|
29
|
+
let handlerToCall = handler;
|
|
30
|
+
if (eyesConfig.eyesIsGlobalHooksSupported && isRunEvent) {
|
|
31
|
+
handlerToCall = handlerThatCallsUserDefinedHandler;
|
|
32
|
+
isGlobalHookCalledFromUserHandler = true;
|
|
33
|
+
}
|
|
24
34
|
return origOn.call(this, eventName, handlerToCall);
|
|
25
35
|
|
|
26
36
|
async function handlerThatCallsUserDefinedHandler() {
|