@applitools/eyes-cypress 3.27.9 → 3.28.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 +13 -0
- package/bin/eyes-setup.js +21 -21
- package/index.d.ts +12 -12
- package/index.js +2 -2
- package/package.json +13 -11
- package/src/browser/commands.js +79 -84
- package/src/browser/eyesCheckMapping.js +69 -71
- package/src/browser/eyesOpenMapping.js +28 -32
- package/src/browser/makeSend.js +5 -10
- package/src/browser/refer.js +28 -28
- package/src/browser/sendRequest.js +6 -6
- package/src/browser/socket.js +72 -73
- package/src/browser/socketCommands.js +34 -45
- package/src/plugin/concurrencyMsg.js +4 -4
- package/src/plugin/config.js +16 -17
- package/src/plugin/configParams.js +3 -3
- package/src/plugin/defaultPort.js +1 -1
- package/src/plugin/errorDigest.js +27 -35
- package/src/plugin/getErrorsAndDiffs.js +11 -11
- package/src/plugin/handleTestResults.js +16 -19
- package/src/plugin/hooks.js +12 -12
- package/src/plugin/isGlobalHooksSupported.js +6 -7
- package/src/plugin/pluginExport.js +38 -43
- package/src/plugin/server.js +50 -53
- package/src/plugin/startPlugin.js +9 -9
- package/src/plugin/webSocket.js +63 -64
- package/src/setup/addEyesCommands.js +12 -12
- package/src/setup/addEyesCypressPlugin.js +6 -6
- package/src/setup/getCypressPaths.js +28 -32
- package/src/setup/getCypressVersion.js +7 -9
- package/src/setup/getFilePath.js +8 -8
- package/src/setup/handleCommands.js +11 -11
- package/src/setup/handlePlugin.js +10 -10
- package/src/setup/handleTypeScript.js +8 -8
- package/src/setup/isCommandsDefined.js +3 -3
- package/src/setup/isPluginDefined.js +3 -3
package/src/browser/socket.js
CHANGED
|
@@ -1,144 +1,143 @@
|
|
|
1
1
|
/* global WebSocket */
|
|
2
|
-
const uuid = require('uuid')
|
|
2
|
+
const uuid = require('uuid')
|
|
3
3
|
|
|
4
4
|
class Socket {
|
|
5
5
|
constructor() {
|
|
6
|
-
this._socket = null
|
|
7
|
-
this._listeners = new Map()
|
|
8
|
-
this._queue = new Set()
|
|
6
|
+
this._socket = null
|
|
7
|
+
this._listeners = new Map()
|
|
8
|
+
this._queue = new Set()
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
attach(ws) {
|
|
12
|
-
if (!ws) return
|
|
12
|
+
if (!ws) return
|
|
13
13
|
|
|
14
|
-
if (ws.readyState === WebSocket.CONNECTING) ws.addEventListener('open', () => this.attach(ws))
|
|
14
|
+
if (ws.readyState === WebSocket.CONNECTING) ws.addEventListener('open', () => this.attach(ws))
|
|
15
15
|
else if (ws.readyState === WebSocket.OPEN) {
|
|
16
|
-
this._socket = ws
|
|
17
|
-
this._queue.forEach(command => command())
|
|
18
|
-
this._queue.clear()
|
|
16
|
+
this._socket = ws
|
|
17
|
+
this._queue.forEach(command => command())
|
|
18
|
+
this._queue.clear()
|
|
19
19
|
|
|
20
20
|
this._socket.addEventListener('message', message => {
|
|
21
|
-
const {name, key, payload} = this.deserialize(message)
|
|
22
|
-
const fns = this._listeners.get(name)
|
|
23
|
-
if (fns) fns.forEach(fn => fn(payload, key))
|
|
21
|
+
const {name, key, payload} = this.deserialize(message)
|
|
22
|
+
const fns = this._listeners.get(name)
|
|
23
|
+
if (fns) fns.forEach(fn => fn(payload, key))
|
|
24
24
|
if (key) {
|
|
25
|
-
const fns = this._listeners.get(`${name}/${key}`)
|
|
26
|
-
if (fns) fns.forEach(fn => fn(payload, key))
|
|
25
|
+
const fns = this._listeners.get(`${name}/${key}`)
|
|
26
|
+
if (fns) fns.forEach(fn => fn(payload, key))
|
|
27
27
|
}
|
|
28
|
-
})
|
|
28
|
+
})
|
|
29
29
|
this._socket.addEventListener('close', () => {
|
|
30
|
-
const fns = this._listeners.get('close')
|
|
31
|
-
if (fns) fns.forEach(fn => fn())
|
|
32
|
-
})
|
|
30
|
+
const fns = this._listeners.get('close')
|
|
31
|
+
if (fns) fns.forEach(fn => fn())
|
|
32
|
+
})
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
on(type, fn) {
|
|
37
|
-
const name = typeof type === 'string' ? type : `${type.name}/${type.key}
|
|
38
|
-
let fns = this._listeners.get(name)
|
|
37
|
+
const name = typeof type === 'string' ? type : `${type.name}/${type.key}`
|
|
38
|
+
let fns = this._listeners.get(name)
|
|
39
39
|
if (!fns) {
|
|
40
|
-
fns = new Set()
|
|
41
|
-
this._listeners.set(name, fns)
|
|
40
|
+
fns = new Set()
|
|
41
|
+
this._listeners.set(name, fns)
|
|
42
42
|
}
|
|
43
|
-
fns.add(fn)
|
|
44
|
-
return () => this.off(name, fn)
|
|
43
|
+
fns.add(fn)
|
|
44
|
+
return () => this.off(name, fn)
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
connect(url) {
|
|
48
|
-
const ws = new WebSocket(url)
|
|
49
|
-
this.attach(ws)
|
|
48
|
+
const ws = new WebSocket(url)
|
|
49
|
+
this.attach(ws)
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
disconnect() {
|
|
53
|
-
if (!this._socket) return
|
|
54
|
-
this._socket.terminate()
|
|
55
|
-
this._socket = null
|
|
53
|
+
if (!this._socket) return
|
|
54
|
+
this._socket.terminate()
|
|
55
|
+
this._socket = null
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
request(name, payload) {
|
|
59
59
|
return new Promise((resolve, reject) => {
|
|
60
60
|
try {
|
|
61
|
-
const key = uuid.v4()
|
|
62
|
-
this.emit({name, key}, payload)
|
|
61
|
+
const key = uuid.v4()
|
|
62
|
+
this.emit({name, key}, payload)
|
|
63
63
|
this.once({name, key}, response => {
|
|
64
|
-
if (response.error) return reject(response.error)
|
|
65
|
-
return resolve(response.result)
|
|
66
|
-
})
|
|
64
|
+
if (response.error) return reject(response.error)
|
|
65
|
+
return resolve(response.result)
|
|
66
|
+
})
|
|
67
67
|
} catch (ex) {
|
|
68
|
-
console.log(ex)
|
|
69
|
-
throw ex
|
|
68
|
+
console.log(ex)
|
|
69
|
+
throw ex
|
|
70
70
|
}
|
|
71
|
-
})
|
|
71
|
+
})
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
command(name, fn) {
|
|
75
75
|
this.on(name, async (payload, key) => {
|
|
76
76
|
try {
|
|
77
|
-
const result = await fn(payload)
|
|
78
|
-
this.emit({name, key}, {result})
|
|
77
|
+
const result = await fn(payload)
|
|
78
|
+
this.emit({name, key}, {result})
|
|
79
79
|
} catch (error) {
|
|
80
|
-
console.log(error)
|
|
81
|
-
this.emit({name, key}, {error})
|
|
80
|
+
console.log(error)
|
|
81
|
+
this.emit({name, key}, {error})
|
|
82
82
|
}
|
|
83
|
-
})
|
|
83
|
+
})
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
subscribe(name, publisher, fn) {
|
|
87
|
-
const subscription = uuid.v4()
|
|
88
|
-
this.emit(name, {publisher, subscription})
|
|
89
|
-
const off = this.on({name, key: subscription}, fn)
|
|
90
|
-
return () => (this.emit({name, key: subscription}), off())
|
|
87
|
+
const subscription = uuid.v4()
|
|
88
|
+
this.emit(name, {publisher, subscription})
|
|
89
|
+
const off = this.on({name, key: subscription}, fn)
|
|
90
|
+
return () => (this.emit({name, key: subscription}), off())
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
once(type, fn) {
|
|
94
|
-
const off = this.on(type, (...args) => (fn(...args), this.off()))
|
|
95
|
-
return off
|
|
94
|
+
const off = this.on(type, (...args) => (fn(...args), this.off()))
|
|
95
|
+
return off
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
off(name, fn) {
|
|
99
|
-
if (!fn) return this._listeners.delete(name)
|
|
100
|
-
const fns = this._listeners.get(name)
|
|
101
|
-
if (!fns) return false
|
|
102
|
-
const existed = fns.delete(fn)
|
|
103
|
-
if (!fns.size) this._listeners.delete(name)
|
|
104
|
-
return existed
|
|
99
|
+
if (!fn) return this._listeners.delete(name)
|
|
100
|
+
const fns = this._listeners.get(name)
|
|
101
|
+
if (!fns) return false
|
|
102
|
+
const existed = fns.delete(fn)
|
|
103
|
+
if (!fns.size) this._listeners.delete(name)
|
|
104
|
+
return existed
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
emit(type, payload) {
|
|
108
108
|
try {
|
|
109
|
-
const command = () => this._socket.send(this.serialize(type, payload))
|
|
110
|
-
if (this._socket) command()
|
|
111
|
-
else this._queue.add(command)
|
|
112
|
-
return () => this._queue.delete(command)
|
|
109
|
+
const command = () => this._socket.send(this.serialize(type, payload))
|
|
110
|
+
if (this._socket) command()
|
|
111
|
+
else this._queue.add(command)
|
|
112
|
+
return () => this._queue.delete(command)
|
|
113
113
|
} catch (ex) {
|
|
114
|
-
console.log(ex)
|
|
115
|
-
throw ex
|
|
114
|
+
console.log(ex)
|
|
115
|
+
throw ex
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
ref() {
|
|
120
|
-
const command = () => this._socket._socket.ref()
|
|
121
|
-
if (this._socket) command()
|
|
122
|
-
else this._queue.add(command)
|
|
123
|
-
return () => this._queue.delete(command)
|
|
120
|
+
const command = () => this._socket._socket.ref()
|
|
121
|
+
if (this._socket) command()
|
|
122
|
+
else this._queue.add(command)
|
|
123
|
+
return () => this._queue.delete(command)
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
unref() {
|
|
127
|
-
const command = () => this._socket._socket.unref()
|
|
128
|
-
if (this._socket) command()
|
|
129
|
-
else this._queue.add(command)
|
|
130
|
-
return () => this._queue.delete(command)
|
|
127
|
+
const command = () => this._socket._socket.unref()
|
|
128
|
+
if (this._socket) command()
|
|
129
|
+
else this._queue.add(command)
|
|
130
|
+
return () => this._queue.delete(command)
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
serialize(type, payload) {
|
|
134
|
-
const message =
|
|
135
|
-
|
|
136
|
-
return JSON.stringify(message);
|
|
134
|
+
const message = typeof type === 'string' ? {name: type, payload} : {name: type.name, key: type.key, payload}
|
|
135
|
+
return JSON.stringify(message)
|
|
137
136
|
}
|
|
138
137
|
|
|
139
138
|
deserialize(message) {
|
|
140
|
-
return JSON.parse(message.data)
|
|
139
|
+
return JSON.parse(message.data)
|
|
141
140
|
}
|
|
142
141
|
}
|
|
143
142
|
|
|
144
|
-
module.exports = Socket
|
|
143
|
+
module.exports = Socket
|
|
@@ -1,83 +1,72 @@
|
|
|
1
|
-
|
|
2
|
-
const spec = require('../../dist/browser/spec-driver');
|
|
1
|
+
const spec = require('../../dist/browser/spec-driver')
|
|
3
2
|
|
|
4
3
|
function socketCommands(socket, refer) {
|
|
5
4
|
socket.command('Driver.executeScript', ({context, script, arg = []}) => {
|
|
6
|
-
const res = spec.executeScript(refer.deref(context), script, derefArgs(arg))
|
|
7
|
-
return res ? refer.ref(res) : res
|
|
8
|
-
})
|
|
5
|
+
const res = spec.executeScript(refer.deref(context), script, derefArgs(arg))
|
|
6
|
+
return res ? refer.ref(res) : res
|
|
7
|
+
})
|
|
9
8
|
|
|
10
9
|
socket.command('Driver.mainContext', () => {
|
|
11
|
-
return refer.ref(spec.mainContext()), {type: 'context'}
|
|
12
|
-
})
|
|
10
|
+
return refer.ref(spec.mainContext()), {type: 'context'}
|
|
11
|
+
})
|
|
13
12
|
|
|
14
13
|
socket.command('Driver.parentContext', ({context}) => {
|
|
15
|
-
return refer.ref(spec.parentContext(refer.deref(context)))
|
|
16
|
-
})
|
|
14
|
+
return refer.ref(spec.parentContext(refer.deref(context)))
|
|
15
|
+
})
|
|
17
16
|
|
|
18
17
|
socket.command('Driver.childContext', ({context, element}) => {
|
|
19
|
-
return refer.ref(spec.childContext(refer.deref(context), refer.deref(element)))
|
|
20
|
-
})
|
|
18
|
+
return refer.ref(spec.childContext(refer.deref(context), refer.deref(element)))
|
|
19
|
+
})
|
|
21
20
|
|
|
22
21
|
socket.command('Driver.getViewportSize', () => {
|
|
23
|
-
return spec.getViewportSize()
|
|
24
|
-
})
|
|
22
|
+
return spec.getViewportSize()
|
|
23
|
+
})
|
|
25
24
|
socket.command('Driver.setViewportSize', vs => {
|
|
26
|
-
spec.setViewportSize(vs)
|
|
27
|
-
})
|
|
25
|
+
spec.setViewportSize(vs)
|
|
26
|
+
})
|
|
28
27
|
socket.command('Driver.findElement', ({context, selector, parent}) => {
|
|
29
|
-
const element = spec.findElement(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
refer.deref(parent),
|
|
33
|
-
);
|
|
34
|
-
return element === null ? element : refer.ref(element, context);
|
|
35
|
-
});
|
|
28
|
+
const element = spec.findElement(refer.deref(context), spec.transformSelector(selector), refer.deref(parent))
|
|
29
|
+
return element === null ? element : refer.ref(element, context)
|
|
30
|
+
})
|
|
36
31
|
socket.command('Driver.findElements', ({context, selector, parent}) => {
|
|
37
|
-
const elements = spec.findElements(
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
refer.deref(parent),
|
|
41
|
-
);
|
|
42
|
-
return Array.prototype.map.call(elements, element =>
|
|
43
|
-
element === null ? element : refer.ref(element, context),
|
|
44
|
-
);
|
|
45
|
-
});
|
|
32
|
+
const elements = spec.findElements(refer.deref(context), spec.transformSelector(selector), refer.deref(parent))
|
|
33
|
+
return Array.prototype.map.call(elements, element => (element === null ? element : refer.ref(element, context)))
|
|
34
|
+
})
|
|
46
35
|
|
|
47
36
|
socket.command('Driver.getUrl', ({driver}) => {
|
|
48
|
-
return spec.getUrl(refer.deref(driver))
|
|
49
|
-
})
|
|
37
|
+
return spec.getUrl(refer.deref(driver))
|
|
38
|
+
})
|
|
50
39
|
|
|
51
40
|
socket.command('Driver.getTitle', ({driver}) => {
|
|
52
|
-
return spec.getTitle(refer.deref(driver))
|
|
53
|
-
})
|
|
41
|
+
return spec.getTitle(refer.deref(driver))
|
|
42
|
+
})
|
|
54
43
|
|
|
55
44
|
socket.command('Driver.getCookies', async () => {
|
|
56
|
-
return await spec.getCookies()
|
|
57
|
-
})
|
|
45
|
+
return await spec.getCookies()
|
|
46
|
+
})
|
|
58
47
|
|
|
59
48
|
// utils
|
|
60
49
|
|
|
61
50
|
function derefArgs(arg) {
|
|
62
|
-
const derefArg = []
|
|
51
|
+
const derefArg = []
|
|
63
52
|
if (Array.isArray(arg)) {
|
|
64
53
|
for (const argument of arg) {
|
|
65
54
|
if (Array.isArray(argument)) {
|
|
66
|
-
derefArg.push(derefArgs(argument))
|
|
55
|
+
derefArg.push(derefArgs(argument))
|
|
67
56
|
} else {
|
|
68
|
-
derefArg.push(refer.deref(argument))
|
|
57
|
+
derefArg.push(refer.deref(argument))
|
|
69
58
|
}
|
|
70
59
|
}
|
|
71
|
-
return derefArg
|
|
60
|
+
return derefArg
|
|
72
61
|
} else if (typeof arg === 'object') {
|
|
73
62
|
for (const [key, value] of Object.entries(arg)) {
|
|
74
|
-
derefArg[key] = refer.deref(value)
|
|
63
|
+
derefArg[key] = refer.deref(value)
|
|
75
64
|
}
|
|
76
|
-
return derefArg
|
|
65
|
+
return derefArg
|
|
77
66
|
} else {
|
|
78
|
-
return arg
|
|
67
|
+
return arg
|
|
79
68
|
}
|
|
80
69
|
}
|
|
81
70
|
}
|
|
82
71
|
|
|
83
|
-
module.exports = {socketCommands}
|
|
72
|
+
module.exports = {socketCommands}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
const chalk = require('chalk')
|
|
1
|
+
'use strict'
|
|
2
|
+
const chalk = require('chalk')
|
|
3
3
|
const MSG = `
|
|
4
4
|
Important notice: Your Applitools visual tests are currently running with a testConcurrency value of 5.
|
|
5
5
|
This means that only up to 5 visual tests can run in parallel, and therefore the execution might be slower.
|
|
6
6
|
If your Applitools license supports a higher concurrency level, learn how to configure it here: https://www.npmjs.com/package/@applitools/eyes-cypress#concurrency.
|
|
7
|
-
Need a higher concurrency in your account? Email us @ sdr@applitools.com with your required concurrency level
|
|
8
|
-
module.exports = {concurrencyMsg: chalk.yellow(MSG), msgText: MSG}
|
|
7
|
+
Need a higher concurrency in your account? Email us @ sdr@applitools.com with your required concurrency level.`
|
|
8
|
+
module.exports = {concurrencyMsg: chalk.yellow(MSG), msgText: MSG}
|
package/src/plugin/config.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
const utils = require('@applitools/utils')
|
|
3
|
-
const {configParams} = require('./configParams')
|
|
4
|
-
const DEFAULT_TEST_CONCURRENCY = 5
|
|
5
|
-
const uuid = require('uuid')
|
|
1
|
+
'use strict'
|
|
2
|
+
const utils = require('@applitools/utils')
|
|
3
|
+
const {configParams} = require('./configParams')
|
|
4
|
+
const DEFAULT_TEST_CONCURRENCY = 5
|
|
5
|
+
const uuid = require('uuid')
|
|
6
6
|
|
|
7
7
|
function makeConfig() {
|
|
8
8
|
const config = utils.config.getConfig({
|
|
@@ -14,27 +14,27 @@ function makeConfig() {
|
|
|
14
14
|
'disableBrowserFetching',
|
|
15
15
|
'testConcurrency',
|
|
16
16
|
],
|
|
17
|
-
})
|
|
17
|
+
})
|
|
18
18
|
|
|
19
19
|
if ((!config.batch || !config.batch.id) && !config.batchId) {
|
|
20
|
-
config.batch = {id: uuid.v4(), ...config.batch}
|
|
20
|
+
config.batch = {id: uuid.v4(), ...config.batch}
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
if (config.failCypressOnDiff === '0') {
|
|
24
|
-
config.failCypressOnDiff = false
|
|
24
|
+
config.failCypressOnDiff = false
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
if (utils.types.isString(config.showLogs)) {
|
|
28
|
-
config.showLogs = config.showLogs === 'true' || config.showLogs === '1'
|
|
28
|
+
config.showLogs = config.showLogs === 'true' || config.showLogs === '1'
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
if (utils.types.isString(config.testConcurrency)) {
|
|
32
|
-
config.testConcurrency = Number(config.testConcurrency)
|
|
32
|
+
config.testConcurrency = Number(config.testConcurrency)
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
if (config.accessibilityValidation) {
|
|
36
|
-
config.accessibilitySettings = config.accessibilityValidation
|
|
37
|
-
delete config.accessiblityValidation
|
|
36
|
+
config.accessibilitySettings = config.accessibilityValidation
|
|
37
|
+
delete config.accessiblityValidation
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
const eyesConfig = {
|
|
@@ -43,14 +43,13 @@ function makeConfig() {
|
|
|
43
43
|
eyesIsDisabled: !!config.isDisabled,
|
|
44
44
|
eyesBrowser: JSON.stringify(config.browser),
|
|
45
45
|
eyesLayoutBreakpoints: JSON.stringify(config.layoutBreakpoints),
|
|
46
|
-
eyesFailCypressOnDiff:
|
|
47
|
-
config.failCypressOnDiff === undefined ? true : !!config.failCypressOnDiff,
|
|
46
|
+
eyesFailCypressOnDiff: config.failCypressOnDiff === undefined ? true : !!config.failCypressOnDiff,
|
|
48
47
|
eyesDisableBrowserFetching: !!config.disableBrowserFetching,
|
|
49
48
|
eyesTestConcurrency: config.testConcurrency || DEFAULT_TEST_CONCURRENCY,
|
|
50
49
|
eyesWaitBeforeCapture: config.waitBeforeCapture,
|
|
51
|
-
}
|
|
50
|
+
}
|
|
52
51
|
|
|
53
|
-
return {config, eyesConfig}
|
|
52
|
+
return {config, eyesConfig}
|
|
54
53
|
}
|
|
55
54
|
|
|
56
|
-
module.exports = makeConfig
|
|
55
|
+
module.exports = makeConfig
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
'use strict'
|
|
1
|
+
'use strict'
|
|
2
2
|
|
|
3
3
|
const configParams = [
|
|
4
4
|
'appName',
|
|
@@ -43,6 +43,6 @@ const configParams = [
|
|
|
43
43
|
'notifyOnCompletion',
|
|
44
44
|
'batchNotify',
|
|
45
45
|
'dontCloseBatches',
|
|
46
|
-
]
|
|
46
|
+
]
|
|
47
47
|
|
|
48
|
-
module.exports = {configParams}
|
|
48
|
+
module.exports = {configParams}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
module.exports = 7373
|
|
1
|
+
module.exports = 7373
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
'use strict'
|
|
1
|
+
'use strict'
|
|
2
2
|
|
|
3
3
|
const colors = {
|
|
4
4
|
green: '\x1b[32m',
|
|
@@ -6,7 +6,7 @@ const colors = {
|
|
|
6
6
|
teal: '\x1b[38;5;86m',
|
|
7
7
|
orange: '\x1b[38;5;214m',
|
|
8
8
|
reset: '\x1b[0m',
|
|
9
|
-
}
|
|
9
|
+
}
|
|
10
10
|
|
|
11
11
|
const formatByStatus = {
|
|
12
12
|
Passed: {
|
|
@@ -24,73 +24,65 @@ const formatByStatus = {
|
|
|
24
24
|
symbol: '\u26A0',
|
|
25
25
|
title: tests => `Diffs detected - ${tests} tests`,
|
|
26
26
|
},
|
|
27
|
-
}
|
|
27
|
+
}
|
|
28
28
|
|
|
29
29
|
function errorDigest({passed, failed, diffs, logger, isInteractive}) {
|
|
30
|
-
logger.log('errorDigest: diff errors', diffs)
|
|
31
|
-
logger.log('errorDigest: test errors', failed)
|
|
30
|
+
logger.log('errorDigest: diff errors', diffs)
|
|
31
|
+
logger.log('errorDigest: test errors', failed)
|
|
32
32
|
|
|
33
|
-
const testResultsUrl = diffs.length ? colorify(diffs[0].url
|
|
34
|
-
const testResultsPrefix = testResultsUrl ? 'See details at:' : ''
|
|
35
|
-
const footer = testResultsUrl
|
|
36
|
-
? `\n${indent()}${colorify(testResultsPrefix)} ${testResultsUrl}`
|
|
37
|
-
: '';
|
|
33
|
+
const testResultsUrl = diffs.length ? colorify(` ${diffs[0].url} `, 'teal') : '' // the space around the url is for the link to be clickable in the cypress run
|
|
34
|
+
const testResultsPrefix = testResultsUrl ? 'See details at:' : ''
|
|
35
|
+
const footer = testResultsUrl ? `\n${indent()}${colorify(testResultsPrefix)}${testResultsUrl}` : ''
|
|
38
36
|
return (
|
|
39
37
|
colorify('Eyes-Cypress detected diffs or errors during execution of visual tests.') +
|
|
40
|
-
colorify(` ${testResultsPrefix}
|
|
38
|
+
colorify(` ${testResultsPrefix}${testResultsUrl}`) +
|
|
41
39
|
testResultsToString(passed, 'Passed') +
|
|
42
40
|
testResultsToString(diffs, 'Unresolved') +
|
|
43
41
|
testResultsToString(failed, 'Failed') +
|
|
44
42
|
footer +
|
|
45
43
|
'\n\n'
|
|
46
|
-
)
|
|
44
|
+
)
|
|
47
45
|
|
|
48
46
|
function testResultsToString(testResultsArr, category) {
|
|
49
|
-
const {color, title, symbol, chalkFunction} = formatByStatus[category]
|
|
47
|
+
const {color, title, symbol, chalkFunction} = formatByStatus[category]
|
|
50
48
|
const results = testResultsArr.reduce((acc, testResults) => {
|
|
51
49
|
if (!testResults.isEmpty) {
|
|
52
|
-
const error = hasError(testResults) ? stringifyError(testResults) : undefined
|
|
53
|
-
acc.push(
|
|
54
|
-
`${colorify(symbol, color)} ${colorify(error || stringifyTestResults(testResults))}`,
|
|
55
|
-
);
|
|
50
|
+
const error = hasError(testResults) ? stringifyError(testResults) : undefined
|
|
51
|
+
acc.push(`${colorify(symbol, color)} ${colorify(error || stringifyTestResults(testResults))}`)
|
|
56
52
|
}
|
|
57
|
-
return acc
|
|
58
|
-
}, [])
|
|
53
|
+
return acc
|
|
54
|
+
}, [])
|
|
59
55
|
|
|
60
|
-
const coloredTitle = results.length
|
|
61
|
-
|
|
62
|
-
: '';
|
|
63
|
-
return testResultsSection(coloredTitle, results);
|
|
56
|
+
const coloredTitle = results.length ? colorify(title(results.length), color, chalkFunction) : ''
|
|
57
|
+
return testResultsSection(coloredTitle, results)
|
|
64
58
|
}
|
|
65
59
|
|
|
66
60
|
function colorify(msg, color = 'reset') {
|
|
67
|
-
return isInteractive ? msg : `${colors[color]}${msg}${colors.reset}
|
|
61
|
+
return isInteractive ? msg : `${colors[color]}${msg}${colors.reset}`
|
|
68
62
|
}
|
|
69
63
|
}
|
|
70
64
|
|
|
71
65
|
function stringifyTestResults(testResults) {
|
|
72
|
-
const hostDisplaySize = testResults.hostDisplaySize
|
|
73
|
-
const viewport = hostDisplaySize ? `[${hostDisplaySize.width}x${hostDisplaySize.height}]` : ''
|
|
74
|
-
const testName = `${testResults.name} ${viewport}
|
|
75
|
-
return testName + (testResults.error ? ` : ${testResults.error}` : '')
|
|
66
|
+
const hostDisplaySize = testResults.hostDisplaySize
|
|
67
|
+
const viewport = hostDisplaySize ? `[${hostDisplaySize.width}x${hostDisplaySize.height}]` : ''
|
|
68
|
+
const testName = `${testResults.name} ${viewport}`
|
|
69
|
+
return testName + (testResults.error ? ` : ${testResults.error}` : '')
|
|
76
70
|
}
|
|
77
71
|
|
|
78
72
|
function testResultsSection(title, results) {
|
|
79
|
-
return results.length ? `${indent()}${title}${indent(3)}${results.join(indent(3))}` : ''
|
|
73
|
+
return results.length ? `${indent()}${title}${indent(3)}${results.join(indent(3))}` : ''
|
|
80
74
|
}
|
|
81
75
|
|
|
82
76
|
function stringifyError(testResults) {
|
|
83
|
-
return testResults.error
|
|
84
|
-
? stringifyTestResults(testResults)
|
|
85
|
-
: `[Eyes test not started] : ${testResults}`;
|
|
77
|
+
return testResults.error ? stringifyTestResults(testResults) : `[Eyes test not started] : ${testResults}`
|
|
86
78
|
}
|
|
87
79
|
|
|
88
80
|
function indent(spaces = 2) {
|
|
89
|
-
return `\n ${' '.repeat(spaces)}
|
|
81
|
+
return `\n ${' '.repeat(spaces)}`
|
|
90
82
|
}
|
|
91
83
|
|
|
92
84
|
function hasError(testResult) {
|
|
93
|
-
return testResult.error || testResult instanceof Error
|
|
85
|
+
return testResult.error || testResult instanceof Error
|
|
94
86
|
}
|
|
95
87
|
|
|
96
|
-
module.exports = errorDigest
|
|
88
|
+
module.exports = errorDigest
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
'use strict'
|
|
1
|
+
'use strict'
|
|
2
2
|
function getErrorsAndDiffs(testResultsArr) {
|
|
3
3
|
return testResultsArr.reduce(
|
|
4
4
|
({failed, diffs, passed}, testResults) => {
|
|
5
5
|
if (testResults instanceof Error || testResults.error) {
|
|
6
|
-
failed.push(testResults)
|
|
6
|
+
failed.push(testResults)
|
|
7
7
|
} else {
|
|
8
|
-
const testStatus = testResults.status
|
|
8
|
+
const testStatus = testResults.status
|
|
9
9
|
if (testStatus === 'Passed') {
|
|
10
|
-
passed.push(testResults)
|
|
10
|
+
passed.push(testResults)
|
|
11
11
|
} else {
|
|
12
12
|
if (testStatus === 'Unresolved') {
|
|
13
13
|
if (testResults.isNew) {
|
|
14
14
|
testResults.error = new Error(
|
|
15
15
|
`${testResults.name}. Please approve the new baseline at ${testResults.url}`,
|
|
16
|
-
)
|
|
17
|
-
failed.push(testResults)
|
|
16
|
+
)
|
|
17
|
+
failed.push(testResults)
|
|
18
18
|
} else {
|
|
19
|
-
diffs.push(testResults)
|
|
19
|
+
diffs.push(testResults)
|
|
20
20
|
}
|
|
21
21
|
} else if (testStatus === 'Failed') {
|
|
22
|
-
failed.push(testResults)
|
|
22
|
+
failed.push(testResults)
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
return {failed, diffs, passed}
|
|
27
|
+
return {failed, diffs, passed}
|
|
28
28
|
},
|
|
29
29
|
{failed: [], diffs: [], passed: []},
|
|
30
|
-
)
|
|
30
|
+
)
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
module.exports = getErrorsAndDiffs
|
|
33
|
+
module.exports = getErrorsAndDiffs
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
const errorDigest = require('./errorDigest')
|
|
2
|
-
const {makeLogger} = require('@applitools/logger')
|
|
3
|
-
const getErrorsAndDiffs = require('./getErrorsAndDiffs')
|
|
4
|
-
const {promisify} = require('util')
|
|
5
|
-
const fs = require('fs')
|
|
6
|
-
const writeFile = promisify(fs.writeFile)
|
|
7
|
-
const {formatters} = require('@applitools/core')
|
|
8
|
-
const {resolve} = require('path')
|
|
1
|
+
const errorDigest = require('./errorDigest')
|
|
2
|
+
const {makeLogger} = require('@applitools/logger')
|
|
3
|
+
const getErrorsAndDiffs = require('./getErrorsAndDiffs')
|
|
4
|
+
const {promisify} = require('util')
|
|
5
|
+
const fs = require('fs')
|
|
6
|
+
const writeFile = promisify(fs.writeFile)
|
|
7
|
+
const {formatters} = require('@applitools/core')
|
|
8
|
+
const {resolve} = require('path')
|
|
9
9
|
|
|
10
10
|
function printTestResults(testResultsArr) {
|
|
11
11
|
const logger = makeLogger({
|
|
12
12
|
level: testResultsArr.resultConfig.showLogs ? 'info' : 'silent',
|
|
13
13
|
label: 'eyes',
|
|
14
|
-
})
|
|
15
|
-
if (!testResultsArr.testResults) return
|
|
16
|
-
const {passed, failed, diffs} = getErrorsAndDiffs(testResultsArr.testResults)
|
|
14
|
+
})
|
|
15
|
+
if (!testResultsArr.testResults) return
|
|
16
|
+
const {passed, failed, diffs} = getErrorsAndDiffs(testResultsArr.testResults)
|
|
17
17
|
if ((failed.length || diffs.length) && !!testResultsArr.resultConfig.eyesFailCypressOnDiff) {
|
|
18
18
|
throw new Error(
|
|
19
19
|
errorDigest({
|
|
@@ -23,16 +23,13 @@ function printTestResults(testResultsArr) {
|
|
|
23
23
|
logger,
|
|
24
24
|
isInteractive: !testResultsArr.resultConfig.isTextTerminal,
|
|
25
25
|
}),
|
|
26
|
-
)
|
|
26
|
+
)
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
function handleBatchResultsFile(results, tapFileConfig) {
|
|
30
|
-
const fileName = tapFileConfig.tapFileName || `${new Date().toISOString()}-eyes.tap
|
|
31
|
-
const tapFile = resolve(tapFileConfig.tapDirPath, fileName)
|
|
32
|
-
return writeFile(
|
|
33
|
-
tapFile,
|
|
34
|
-
formatters.toHierarchicTAPString(results, {includeSubTests: false, markNewAsPassed: true}),
|
|
35
|
-
);
|
|
30
|
+
const fileName = tapFileConfig.tapFileName || `${new Date().toISOString()}-eyes.tap`
|
|
31
|
+
const tapFile = resolve(tapFileConfig.tapDirPath, fileName)
|
|
32
|
+
return writeFile(tapFile, formatters.toHierarchicTAPString(results, {includeSubTests: false, markNewAsPassed: true}))
|
|
36
33
|
}
|
|
37
34
|
|
|
38
|
-
module.exports = {printTestResults, handleBatchResultsFile}
|
|
35
|
+
module.exports = {printTestResults, handleBatchResultsFile}
|