@applitools/eyes-cypress 3.23.9 → 3.24.0-beta.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 +2187 -2185
- package/LICENSE +25 -25
- package/README.md +778 -769
- package/commands.js +2 -2
- package/dist/browser/spec-driver.js +104 -0
- package/dist/plugin/handler.js +55 -0
- package/eyes-index.d.ts +34 -34
- package/index.js +2 -2
- package/package.json +97 -81
- package/src/browser/commands.js +167 -147
- package/src/browser/eyesCheckMapping.js +71 -0
- package/src/browser/eyesOpenMapping.js +34 -0
- package/src/browser/makeSend.js +18 -22
- package/src/browser/refer.js +57 -0
- package/src/browser/sendRequest.js +16 -16
- package/src/browser/socket.js +143 -0
- package/src/browser/socketCommands.js +81 -0
- package/src/browser/spec-driver.ts +109 -0
- package/src/pem/server.cert +22 -22
- package/src/pem/server.key +27 -27
- package/src/plugin/concurrencyMsg.js +8 -8
- package/src/plugin/config.js +54 -53
- package/src/plugin/defaultPort.js +1 -1
- package/src/plugin/errorDigest.js +96 -96
- package/src/plugin/getErrorsAndDiffs.js +34 -34
- package/src/plugin/handleTestResults.js +39 -0
- package/src/plugin/handler.ts +58 -0
- package/src/plugin/hooks.js +49 -42
- package/src/plugin/isGlobalHooksSupported.js +13 -13
- package/src/plugin/pluginExport.js +60 -57
- package/src/plugin/server.js +98 -46
- package/src/plugin/startPlugin.js +13 -34
- package/src/plugin/webSocket.js +130 -0
- package/src/setup/addEyesCommands.js +24 -24
- package/src/setup/addEyesCypressPlugin.js +15 -15
- package/src/setup/getCypressConfig.js +16 -16
- package/src/setup/getFilePath.js +22 -22
- package/src/setup/handleCommands.js +23 -23
- package/src/setup/handlePlugin.js +23 -23
- package/src/setup/handleTypeScript.js +21 -21
- package/src/setup/isCommandsDefined.js +7 -7
- package/src/setup/isPluginDefined.js +7 -7
- package/test/fixtures/testAppCopies/.gitignore +1 -1
- package/bin/eyes-setup.js +0 -21
- package/src/browser/eyesCheckWindow.js +0 -132
- package/src/browser/getAllBlobs.js +0 -14
- package/src/browser/getBrowserInfo.js +0 -39
- package/src/browser/makeHandleCypressViewport.js +0 -22
- package/src/browser/poll.js +0 -25
- package/src/plugin/app.js +0 -42
- package/src/plugin/handlers.js +0 -205
- package/src/plugin/makeHandleBatchResultsFile.js +0 -17
- package/src/plugin/pollingHandler.js +0 -46
- package/src/plugin/processCloseAndAbort.js +0 -33
- package/src/plugin/runningTests.js +0 -27
- package/src/plugin/waitForBatch.js +0 -33
package/src/plugin/server.js
CHANGED
|
@@ -1,46 +1,98 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
const {makeHandler} = require('../../dist/plugin/handler');
|
|
3
|
+
const connectSocket = require('./webSocket');
|
|
4
|
+
const {makeServerProcess} = require('@applitools/eyes-universal');
|
|
5
|
+
const {TestResults} = require('@applitools/visual-grid-client');
|
|
6
|
+
const handleTestResults = require('./handleTestResults');
|
|
7
|
+
|
|
8
|
+
function makeStartServer() {
|
|
9
|
+
return async function startServer() {
|
|
10
|
+
const {server, port} = await makeHandler({});
|
|
11
|
+
// const {port: universalPort, close: closeUniversalServer} = {port: 21077, close: () => {}}; //await makeServerProcess();
|
|
12
|
+
const {port: universalPort, close: closeUniversalServer} = await makeServerProcess();
|
|
13
|
+
|
|
14
|
+
const managers = [];
|
|
15
|
+
let socketWithUniversal;
|
|
16
|
+
|
|
17
|
+
server.on('connection', socketWithClient => {
|
|
18
|
+
socketWithUniversal = connectSocket(`ws://localhost:${universalPort}/eyes`);
|
|
19
|
+
|
|
20
|
+
socketWithUniversal.setPassthroughListener(message => {
|
|
21
|
+
console.log('<== ', message.toString().slice(0, 1000));
|
|
22
|
+
const {name, payload} = JSON.parse(message);
|
|
23
|
+
if (name === 'Core.makeManager') {
|
|
24
|
+
managers.push({manager: payload.result, socketWithUniversal});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
socketWithClient.send(message.toString());
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
socketWithClient.on('message', message => {
|
|
31
|
+
const msg = JSON.parse(message);
|
|
32
|
+
console.log('==> ', message.toString().slice(0, 1000));
|
|
33
|
+
if (msg.name === 'Test.printTestResults') {
|
|
34
|
+
try {
|
|
35
|
+
const resultArr = [];
|
|
36
|
+
for (const result of msg.payload.testResults) {
|
|
37
|
+
resultArr.push(new TestResults(result));
|
|
38
|
+
}
|
|
39
|
+
if (msg.payload.resultConfig.tapDirPath) {
|
|
40
|
+
handleTestResults.handleBatchResultsFile(resultArr, {
|
|
41
|
+
tapFileName: msg.payload.resultConfig.tapFileName,
|
|
42
|
+
tapDirPath: msg.payload.resultConfig.tapDirPath,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
handleTestResults.printTestResults({
|
|
46
|
+
testResults: resultArr,
|
|
47
|
+
resultConfig: msg.payload.resultConfig,
|
|
48
|
+
});
|
|
49
|
+
socketWithClient.send(
|
|
50
|
+
JSON.stringify({
|
|
51
|
+
name: 'Test.printTestResults',
|
|
52
|
+
key: msg.key,
|
|
53
|
+
payload: {result: 'success'},
|
|
54
|
+
}),
|
|
55
|
+
);
|
|
56
|
+
} catch (ex) {
|
|
57
|
+
socketWithClient.send(
|
|
58
|
+
JSON.stringify({
|
|
59
|
+
name: 'Test.printTestResults',
|
|
60
|
+
key: msg.key,
|
|
61
|
+
payload: {result: ex.message.toString()},
|
|
62
|
+
}),
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
} else {
|
|
66
|
+
socketWithUniversal.send(message);
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
return {
|
|
72
|
+
server,
|
|
73
|
+
port,
|
|
74
|
+
closeAllEyes,
|
|
75
|
+
closeBatches,
|
|
76
|
+
closeUniversalServer,
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
function closeAllEyes() {
|
|
80
|
+
return Promise.all(
|
|
81
|
+
managers.map(({manager, socketWithUniversal}) =>
|
|
82
|
+
socketWithUniversal.request('EyesManager.closeAllEyes', {
|
|
83
|
+
manager,
|
|
84
|
+
throwErr: false,
|
|
85
|
+
}),
|
|
86
|
+
),
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
function closeBatches(settings) {
|
|
90
|
+
if (socketWithUniversal)
|
|
91
|
+
return socketWithUniversal.request('Core.closeBatches', {settings}).catch(err => {
|
|
92
|
+
console.log('@@@', err);
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
module.exports = makeStartServer;
|
|
@@ -1,34 +1,13 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
const makeStartServer = require('./server');
|
|
5
|
-
|
|
6
|
-
const {
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const {config, eyesConfig} = makeConfig();
|
|
15
|
-
const logger = makeLogger({level: config.showLogs ? 'info' : 'silent', label: 'eyes'});
|
|
16
|
-
|
|
17
|
-
const visualGridClient = makeVisualGridClient({...config, logger: logger.extend('vgc')});
|
|
18
|
-
|
|
19
|
-
const handlers = makeHandlers({
|
|
20
|
-
logger,
|
|
21
|
-
config,
|
|
22
|
-
visualGridClient,
|
|
23
|
-
processCloseAndAbort,
|
|
24
|
-
getErrorsAndDiffs,
|
|
25
|
-
errorDigest,
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
const globalHooks = makeGlobalRunHooks({visualGridClient, logger});
|
|
29
|
-
|
|
30
|
-
const app = startApp({handlers, logger});
|
|
31
|
-
const startServer = makeStartServer({app, logger});
|
|
32
|
-
logger.log('eyes-cypress plugin running with config:', config);
|
|
33
|
-
|
|
34
|
-
module.exports = makePluginExport({startServer, eyesConfig, globalHooks});
|
|
1
|
+
'use strict';
|
|
2
|
+
const makePluginExport = require('./pluginExport');
|
|
3
|
+
const makeConfig = require('./config');
|
|
4
|
+
const makeStartServer = require('./server');
|
|
5
|
+
|
|
6
|
+
const {config, eyesConfig} = makeConfig();
|
|
7
|
+
|
|
8
|
+
const startServer = makeStartServer();
|
|
9
|
+
|
|
10
|
+
module.exports = makePluginExport({
|
|
11
|
+
startServer,
|
|
12
|
+
eyesConfig: Object.assign({}, eyesConfig, {appliConfFile: config}),
|
|
13
|
+
});
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
const WebSocket = require('ws');
|
|
2
|
+
const {v4: uuid} = require('uuid');
|
|
3
|
+
|
|
4
|
+
function connectSocket(url) {
|
|
5
|
+
const socket = new WebSocket(url);
|
|
6
|
+
let passthroughListener;
|
|
7
|
+
const listeners = new Map();
|
|
8
|
+
const queue = new Set();
|
|
9
|
+
let isReady = false;
|
|
10
|
+
|
|
11
|
+
attach();
|
|
12
|
+
|
|
13
|
+
function attach() {
|
|
14
|
+
if (socket.readyState === WebSocket.CONNECTING) socket.on('open', () => attach(socket));
|
|
15
|
+
else if (socket.readyState === WebSocket.OPEN) {
|
|
16
|
+
isReady = true;
|
|
17
|
+
queue.forEach(command => command());
|
|
18
|
+
queue.clear();
|
|
19
|
+
|
|
20
|
+
socket.on('message', message => {
|
|
21
|
+
const {name, key, payload} = deserialize(message);
|
|
22
|
+
const fns = listeners.get(name);
|
|
23
|
+
const keyListeners = key && listeners.get(`${name}/${key}`);
|
|
24
|
+
if (fns) fns.forEach(fn => fn(payload, key));
|
|
25
|
+
if (keyListeners) keyListeners.forEach(fn => fn(payload, key));
|
|
26
|
+
|
|
27
|
+
if (!fns && !keyListeners && passthroughListener) {
|
|
28
|
+
passthroughListener(message);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function disconnect() {
|
|
35
|
+
if (!socket) return;
|
|
36
|
+
socket.terminate();
|
|
37
|
+
isReady = false;
|
|
38
|
+
passthroughListener = null;
|
|
39
|
+
queue.clear();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function setPassthroughListener(fn) {
|
|
43
|
+
passthroughListener = fn;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function send(message) {
|
|
47
|
+
const command = () => socket.send(message);
|
|
48
|
+
if (isReady) command();
|
|
49
|
+
else queue.add(command);
|
|
50
|
+
return () => queue.delete(command);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function on(type, fn) {
|
|
54
|
+
const name = typeof type === 'string' ? type : `${type.name}/${type.key}`;
|
|
55
|
+
let fns = listeners.get(name);
|
|
56
|
+
if (!fns) {
|
|
57
|
+
fns = new Set();
|
|
58
|
+
listeners.set(name, fns);
|
|
59
|
+
}
|
|
60
|
+
fns.add(fn);
|
|
61
|
+
return () => off(name, fn);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function once(type, fn) {
|
|
65
|
+
const off = on(type, (...args) => (fn(...args), off()));
|
|
66
|
+
return off;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function off(name, fn) {
|
|
70
|
+
if (!fn) return listeners.delete(name);
|
|
71
|
+
const fns = listeners.get(name);
|
|
72
|
+
if (!fns) return false;
|
|
73
|
+
const existed = fns.delete(fn);
|
|
74
|
+
if (!fns.size) listeners.delete(name);
|
|
75
|
+
return existed;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function emit(type, payload) {
|
|
79
|
+
return send(serialize(type, payload));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function request(name, payload) {
|
|
83
|
+
return new Promise((resolve, reject) => {
|
|
84
|
+
const key = uuid();
|
|
85
|
+
emit({name, key}, payload);
|
|
86
|
+
once({name, key}, response => {
|
|
87
|
+
if (response.error) return reject(response.error);
|
|
88
|
+
return resolve(response.result);
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function ref() {
|
|
94
|
+
const command = () => socket._socket.ref();
|
|
95
|
+
if (isReady) command();
|
|
96
|
+
else queue.add(command);
|
|
97
|
+
return () => queue.delete(command);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function unref() {
|
|
101
|
+
const command = () => socket._socket.unref();
|
|
102
|
+
if (isReady) command();
|
|
103
|
+
else queue.add(command);
|
|
104
|
+
return () => queue.delete(command);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return {
|
|
108
|
+
setPassthroughListener,
|
|
109
|
+
send,
|
|
110
|
+
on,
|
|
111
|
+
once,
|
|
112
|
+
off,
|
|
113
|
+
request,
|
|
114
|
+
disconnect,
|
|
115
|
+
ref,
|
|
116
|
+
unref,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function serialize(type, payload) {
|
|
121
|
+
const message =
|
|
122
|
+
typeof type === 'string' ? {name: type, payload} : {name: type.name, key: type.key, payload};
|
|
123
|
+
return JSON.stringify(message);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function deserialize(message) {
|
|
127
|
+
return JSON.parse(message);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
module.exports = connectSocket;
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const commandsImport = `\nimport '@applitools/eyes-cypress/commands'\n`;
|
|
4
|
-
const oldName = `eyes.cypress`;
|
|
5
|
-
|
|
6
|
-
function shouldSkipLine(line) {
|
|
7
|
-
return line && (line.trim() === '' || /^\s*['"]use strict/.test(line) || /^\s*\/\//.test(line));
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
function addEyesCommands(content) {
|
|
11
|
-
if (content.includes(oldName)) {
|
|
12
|
-
return content.replace(oldName, 'eyes-cypress');
|
|
13
|
-
}
|
|
14
|
-
const lines = content.split('\n');
|
|
15
|
-
let i = 0;
|
|
16
|
-
while (shouldSkipLine(lines[i++])) {}
|
|
17
|
-
let index = i === 1 ? i : i - 1;
|
|
18
|
-
lines.splice(index, 0, commandsImport);
|
|
19
|
-
|
|
20
|
-
return lines.join('\n');
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
module.exports = addEyesCommands;
|
|
24
|
-
module.exports.commandsImport = commandsImport;
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const commandsImport = `\nimport '@applitools/eyes-cypress/commands'\n`;
|
|
4
|
+
const oldName = `eyes.cypress`;
|
|
5
|
+
|
|
6
|
+
function shouldSkipLine(line) {
|
|
7
|
+
return line && (line.trim() === '' || /^\s*['"]use strict/.test(line) || /^\s*\/\//.test(line));
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function addEyesCommands(content) {
|
|
11
|
+
if (content.includes(oldName)) {
|
|
12
|
+
return content.replace(oldName, 'eyes-cypress');
|
|
13
|
+
}
|
|
14
|
+
const lines = content.split('\n');
|
|
15
|
+
let i = 0;
|
|
16
|
+
while (shouldSkipLine(lines[i++])) {}
|
|
17
|
+
let index = i === 1 ? i : i - 1;
|
|
18
|
+
lines.splice(index, 0, commandsImport);
|
|
19
|
+
|
|
20
|
+
return lines.join('\n');
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
module.exports = addEyesCommands;
|
|
24
|
+
module.exports.commandsImport = commandsImport;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const pluginRequire = `\n\nrequire('@applitools/eyes-cypress')(module);\n`;
|
|
4
|
-
const oldName = `eyes.cypress`;
|
|
5
|
-
|
|
6
|
-
function addEyesCypressPlugin(content) {
|
|
7
|
-
if (!content.includes(oldName)) {
|
|
8
|
-
return content.replace(/([\s\S])$/, `$1${pluginRequire}`);
|
|
9
|
-
} else {
|
|
10
|
-
return content.replace(oldName, 'eyes-cypress');
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
module.exports = addEyesCypressPlugin;
|
|
15
|
-
module.exports.pluginRequire = pluginRequire;
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const pluginRequire = `\n\nrequire('@applitools/eyes-cypress')(module);\n`;
|
|
4
|
+
const oldName = `eyes.cypress`;
|
|
5
|
+
|
|
6
|
+
function addEyesCypressPlugin(content) {
|
|
7
|
+
if (!content.includes(oldName)) {
|
|
8
|
+
return content.replace(/([\s\S])$/, `$1${pluginRequire}`);
|
|
9
|
+
} else {
|
|
10
|
+
return content.replace(oldName, 'eyes-cypress');
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
module.exports = addEyesCypressPlugin;
|
|
15
|
+
module.exports.pluginRequire = pluginRequire;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const {readFileSync} = require('fs');
|
|
4
|
-
const {resolve} = require('path');
|
|
5
|
-
const chalk = require('chalk');
|
|
6
|
-
|
|
7
|
-
function getCypressConfig(cwd) {
|
|
8
|
-
const cypressConfigPath = resolve(cwd, 'cypress.json');
|
|
9
|
-
try {
|
|
10
|
-
return JSON.parse(readFileSync(cypressConfigPath));
|
|
11
|
-
} catch (ex) {
|
|
12
|
-
console.log(chalk.red('cypress.json not found at ', cypressConfigPath));
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
module.exports = getCypressConfig;
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const {readFileSync} = require('fs');
|
|
4
|
+
const {resolve} = require('path');
|
|
5
|
+
const chalk = require('chalk');
|
|
6
|
+
|
|
7
|
+
function getCypressConfig(cwd) {
|
|
8
|
+
const cypressConfigPath = resolve(cwd, 'cypress.json');
|
|
9
|
+
try {
|
|
10
|
+
return JSON.parse(readFileSync(cypressConfigPath));
|
|
11
|
+
} catch (ex) {
|
|
12
|
+
console.log(chalk.red('cypress.json not found at ', cypressConfigPath));
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
module.exports = getCypressConfig;
|
package/src/setup/getFilePath.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const {resolve, join, dirname} = require('path');
|
|
4
|
-
|
|
5
|
-
function getFilePath(type, cypressConfig, cwd) {
|
|
6
|
-
let filePath = {
|
|
7
|
-
plugins: join('cypress', 'plugins', 'index.js'),
|
|
8
|
-
support: join('cypress', 'support', 'index.js'),
|
|
9
|
-
typeScript: join('cypress', 'support', 'eyes-index.d.ts'),
|
|
10
|
-
}[type];
|
|
11
|
-
|
|
12
|
-
if (type === 'typeScript' && cypressConfig && cypressConfig[`supportFile`]) {
|
|
13
|
-
const supportDir = dirname(cypressConfig[`supportFile`]);
|
|
14
|
-
filePath = resolve(supportDir, 'eyes-index.d.ts');
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
filePath = (cypressConfig && cypressConfig[`${type}File`]) || filePath;
|
|
18
|
-
|
|
19
|
-
return resolve(cwd, filePath);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
module.exports = getFilePath;
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const {resolve, join, dirname} = require('path');
|
|
4
|
+
|
|
5
|
+
function getFilePath(type, cypressConfig, cwd) {
|
|
6
|
+
let filePath = {
|
|
7
|
+
plugins: join('cypress', 'plugins', 'index.js'),
|
|
8
|
+
support: join('cypress', 'support', 'index.js'),
|
|
9
|
+
typeScript: join('cypress', 'support', 'eyes-index.d.ts'),
|
|
10
|
+
}[type];
|
|
11
|
+
|
|
12
|
+
if (type === 'typeScript' && cypressConfig && cypressConfig[`supportFile`]) {
|
|
13
|
+
const supportDir = dirname(cypressConfig[`supportFile`]);
|
|
14
|
+
filePath = resolve(supportDir, 'eyes-index.d.ts');
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
filePath = (cypressConfig && cypressConfig[`${type}File`]) || filePath;
|
|
18
|
+
|
|
19
|
+
return resolve(cwd, filePath);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
module.exports = getFilePath;
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const chalk = require('chalk');
|
|
4
|
-
const {readFileSync, writeFileSync} = require('fs');
|
|
5
|
-
const addEyesCommands = require('./addEyesCommands');
|
|
6
|
-
const isCommandsDefined = require('./isCommandsDefined');
|
|
7
|
-
const getFilePath = require('./getFilePath');
|
|
8
|
-
const getCypressConfig = require('./getCypressConfig');
|
|
9
|
-
|
|
10
|
-
function handleCommands(cwd) {
|
|
11
|
-
const cypressConfig = getCypressConfig(cwd);
|
|
12
|
-
const commandsFilePath = getFilePath('support', cypressConfig, cwd);
|
|
13
|
-
const commandsFileContent = readFileSync(commandsFilePath).toString();
|
|
14
|
-
|
|
15
|
-
if (!isCommandsDefined(commandsFileContent)) {
|
|
16
|
-
writeFileSync(commandsFilePath, addEyesCommands(commandsFileContent));
|
|
17
|
-
console.log(chalk.cyan('Commands defined.'));
|
|
18
|
-
} else {
|
|
19
|
-
console.log(chalk.cyan('Commands already defined.'));
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
module.exports = handleCommands;
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const chalk = require('chalk');
|
|
4
|
+
const {readFileSync, writeFileSync} = require('fs');
|
|
5
|
+
const addEyesCommands = require('./addEyesCommands');
|
|
6
|
+
const isCommandsDefined = require('./isCommandsDefined');
|
|
7
|
+
const getFilePath = require('./getFilePath');
|
|
8
|
+
const getCypressConfig = require('./getCypressConfig');
|
|
9
|
+
|
|
10
|
+
function handleCommands(cwd) {
|
|
11
|
+
const cypressConfig = getCypressConfig(cwd);
|
|
12
|
+
const commandsFilePath = getFilePath('support', cypressConfig, cwd);
|
|
13
|
+
const commandsFileContent = readFileSync(commandsFilePath).toString();
|
|
14
|
+
|
|
15
|
+
if (!isCommandsDefined(commandsFileContent)) {
|
|
16
|
+
writeFileSync(commandsFilePath, addEyesCommands(commandsFileContent));
|
|
17
|
+
console.log(chalk.cyan('Commands defined.'));
|
|
18
|
+
} else {
|
|
19
|
+
console.log(chalk.cyan('Commands already defined.'));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
module.exports = handleCommands;
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const {readFileSync, writeFileSync} = require('fs');
|
|
4
|
-
const chalk = require('chalk');
|
|
5
|
-
const addEyesCypressPlugin = require('./addEyesCypressPlugin');
|
|
6
|
-
const isPluginDefined = require('./isPluginDefined');
|
|
7
|
-
const getFilePath = require('./getFilePath');
|
|
8
|
-
const getCypressConfig = require('./getCypressConfig');
|
|
9
|
-
|
|
10
|
-
function handlePlugin(cwd) {
|
|
11
|
-
const cypressConfig = getCypressConfig(cwd);
|
|
12
|
-
const pluginsFilePath = getFilePath('plugins', cypressConfig, cwd);
|
|
13
|
-
const pluginsFileContent = readFileSync(pluginsFilePath).toString();
|
|
14
|
-
|
|
15
|
-
if (!isPluginDefined(pluginsFileContent)) {
|
|
16
|
-
writeFileSync(pluginsFilePath, addEyesCypressPlugin(pluginsFileContent));
|
|
17
|
-
console.log(chalk.cyan('Plugins defined.'));
|
|
18
|
-
} else {
|
|
19
|
-
console.log(chalk.cyan('Plugins already defined'));
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
module.exports = handlePlugin;
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const {readFileSync, writeFileSync} = require('fs');
|
|
4
|
+
const chalk = require('chalk');
|
|
5
|
+
const addEyesCypressPlugin = require('./addEyesCypressPlugin');
|
|
6
|
+
const isPluginDefined = require('./isPluginDefined');
|
|
7
|
+
const getFilePath = require('./getFilePath');
|
|
8
|
+
const getCypressConfig = require('./getCypressConfig');
|
|
9
|
+
|
|
10
|
+
function handlePlugin(cwd) {
|
|
11
|
+
const cypressConfig = getCypressConfig(cwd);
|
|
12
|
+
const pluginsFilePath = getFilePath('plugins', cypressConfig, cwd);
|
|
13
|
+
const pluginsFileContent = readFileSync(pluginsFilePath).toString();
|
|
14
|
+
|
|
15
|
+
if (!isPluginDefined(pluginsFileContent)) {
|
|
16
|
+
writeFileSync(pluginsFilePath, addEyesCypressPlugin(pluginsFileContent));
|
|
17
|
+
console.log(chalk.cyan('Plugins defined.'));
|
|
18
|
+
} else {
|
|
19
|
+
console.log(chalk.cyan('Plugins already defined'));
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
module.exports = handlePlugin;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
const chalk = require('chalk');
|
|
3
|
-
const {writeFileSync, existsSync} = require('fs');
|
|
4
|
-
const getFilePath = require('./getFilePath');
|
|
5
|
-
const getCypressConfig = require('./getCypressConfig');
|
|
6
|
-
const eyesIndexContent = `import "@applitools/eyes-cypress"`;
|
|
7
|
-
|
|
8
|
-
function handleTypeScript(cwd) {
|
|
9
|
-
const cypressConfig = getCypressConfig(cwd);
|
|
10
|
-
const typeScriptFilePath = getFilePath('typeScript', cypressConfig, cwd);
|
|
11
|
-
|
|
12
|
-
if (!existsSync(typeScriptFilePath)) {
|
|
13
|
-
writeFileSync(typeScriptFilePath, eyesIndexContent);
|
|
14
|
-
console.log(chalk.cyan('Typescript defined.'));
|
|
15
|
-
} else {
|
|
16
|
-
console.log(chalk.cyan('Typescript already defined.'));
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
module.exports = handleTypeScript;
|
|
21
|
-
module.exports.eyesIndexContent = eyesIndexContent;
|
|
1
|
+
'use strict';
|
|
2
|
+
const chalk = require('chalk');
|
|
3
|
+
const {writeFileSync, existsSync} = require('fs');
|
|
4
|
+
const getFilePath = require('./getFilePath');
|
|
5
|
+
const getCypressConfig = require('./getCypressConfig');
|
|
6
|
+
const eyesIndexContent = `import "@applitools/eyes-cypress"`;
|
|
7
|
+
|
|
8
|
+
function handleTypeScript(cwd) {
|
|
9
|
+
const cypressConfig = getCypressConfig(cwd);
|
|
10
|
+
const typeScriptFilePath = getFilePath('typeScript', cypressConfig, cwd);
|
|
11
|
+
|
|
12
|
+
if (!existsSync(typeScriptFilePath)) {
|
|
13
|
+
writeFileSync(typeScriptFilePath, eyesIndexContent);
|
|
14
|
+
console.log(chalk.cyan('Typescript defined.'));
|
|
15
|
+
} else {
|
|
16
|
+
console.log(chalk.cyan('Typescript already defined.'));
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
module.exports = handleTypeScript;
|
|
21
|
+
module.exports.eyesIndexContent = eyesIndexContent;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
function isCommandsDefined(content) {
|
|
4
|
-
return !!content.match(/['"]@applitools\/eyes-cypress\/commands['"]\s*/);
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
module.exports = isCommandsDefined;
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function isCommandsDefined(content) {
|
|
4
|
+
return !!content.match(/['"]@applitools\/eyes-cypress\/commands['"]\s*/);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
module.exports = isCommandsDefined;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
function isPluginDefined(content) {
|
|
4
|
-
return !!content.match(/require\s*\(\s*['"]@applitools\/eyes-cypress['"]\s*\)/);
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
module.exports = isPluginDefined;
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function isPluginDefined(content) {
|
|
4
|
+
return !!content.match(/require\s*\(\s*['"]@applitools\/eyes-cypress['"]\s*\)/);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
module.exports = isPluginDefined;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
*
|
|
1
|
+
*
|
|
2
2
|
!.gitignore
|