@applitools/eyes-cypress 3.28.0 → 3.28.2
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/dist/browser/spec-driver.js +2 -5
- package/index.d.ts +7 -6
- package/index.js +2 -2
- package/package.json +13 -11
- package/src/browser/commands.js +79 -84
- package/src/browser/eyesCheckMapping.js +77 -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/browser/spec-driver.ts +33 -41
- 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,24 +1,19 @@
|
|
|
1
1
|
type EyesSelector = {selector: string; type?: string}
|
|
2
|
-
export type Selector = (string | EyesSelector) & {__applitoolsBrand?: never}
|
|
3
|
-
export type Context = Document & {__applitoolsBrand?: never}
|
|
4
|
-
export type Element = HTMLElement & {__applitoolsBrand?: never}
|
|
5
|
-
|
|
6
|
-
export function executeScript(context: Context, script: string, arg: any): any {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
scriptToExecute = prepScirpt.concat(' return func(arg)')
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const executor = new context.defaultView.Function('arg', scriptToExecute);
|
|
21
|
-
return executor(arg)
|
|
2
|
+
export type Selector = (string | EyesSelector) & {__applitoolsBrand?: never}
|
|
3
|
+
export type Context = Document & {__applitoolsBrand?: never}
|
|
4
|
+
export type Element = HTMLElement & {__applitoolsBrand?: never}
|
|
5
|
+
|
|
6
|
+
export function executeScript(context: Context, script: string, arg: any): any {
|
|
7
|
+
let scriptToExecute
|
|
8
|
+
if (script.includes('dom-snapshot') || script.includes('dom-capture') || script.includes('dom-shared')) {
|
|
9
|
+
scriptToExecute = script
|
|
10
|
+
} else {
|
|
11
|
+
const prepScirpt = script.replace('function(arg)', 'function func(arg)')
|
|
12
|
+
scriptToExecute = prepScirpt.concat(' return func(arg)')
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const executor = new context.defaultView.Function('arg', scriptToExecute)
|
|
16
|
+
return executor(arg)
|
|
22
17
|
}
|
|
23
18
|
|
|
24
19
|
export function mainContext(): Context {
|
|
@@ -30,14 +25,13 @@ export function parentContext(context: Context): Context {
|
|
|
30
25
|
// because Cypress doesn't support cross origin iframe, then childContext might return null, and then the input to parentContext might be null
|
|
31
26
|
if (!context) {
|
|
32
27
|
throw new Error('Context is not accessible')
|
|
33
|
-
}
|
|
34
|
-
|
|
28
|
+
}
|
|
29
|
+
|
|
35
30
|
return context === mainContext() ? context : context.defaultView.frameElement.ownerDocument
|
|
36
31
|
}
|
|
37
32
|
|
|
38
33
|
export function childContext(_context: Context, element: HTMLIFrameElement): Context {
|
|
39
|
-
if(element.contentDocument)
|
|
40
|
-
return element.contentDocument
|
|
34
|
+
if (element.contentDocument) return element.contentDocument
|
|
41
35
|
else {
|
|
42
36
|
throw new Error('Context is not accessible')
|
|
43
37
|
}
|
|
@@ -47,48 +41,47 @@ export function getViewportSize(): Object {
|
|
|
47
41
|
//@ts-ignore
|
|
48
42
|
const currWindow = cy.state('window')
|
|
49
43
|
const viewportSize = {
|
|
50
|
-
width:
|
|
51
|
-
height: currWindow.innerHeight || currWindow.document.documentElement.clientHeight || currWindow.document.body.clientHeight
|
|
52
|
-
}
|
|
53
|
-
return viewportSize
|
|
44
|
+
width: currWindow.innerWidth || currWindow.document.documentElement.clientWidth || currWindow.document.body.clientWidth,
|
|
45
|
+
height: currWindow.innerHeight || currWindow.document.documentElement.clientHeight || currWindow.document.body.clientHeight,
|
|
46
|
+
}
|
|
47
|
+
return viewportSize
|
|
54
48
|
}
|
|
55
49
|
|
|
56
50
|
export function setViewportSize(vs: any): void {
|
|
57
51
|
//@ts-ignore
|
|
58
|
-
Cypress.action('cy:viewport:changed', {
|
|
52
|
+
Cypress.action('cy:viewport:changed', {viewportWidth: vs.size.width, viewportHeight: vs.size.height})
|
|
59
53
|
}
|
|
60
54
|
|
|
61
55
|
export function transformSelector(selector: Selector): Selector {
|
|
62
56
|
if (selector.hasOwnProperty('selector') && (!selector.hasOwnProperty('type') || (selector as EyesSelector).type === 'css')) {
|
|
63
57
|
return (selector as EyesSelector).selector
|
|
64
|
-
}
|
|
58
|
+
}
|
|
65
59
|
return selector
|
|
66
60
|
}
|
|
67
61
|
|
|
68
62
|
export function findElement(context: Context, selector: Selector, parent?: Element) {
|
|
69
|
-
const eyesSelector =
|
|
63
|
+
const eyesSelector = selector as EyesSelector
|
|
70
64
|
const root = parent ?? context
|
|
71
65
|
const sel = typeof selector === 'string' ? selector : eyesSelector.selector
|
|
72
66
|
if (typeof selector !== 'string' && eyesSelector.type === 'xpath') {
|
|
73
|
-
return context.evaluate(sel, context, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue
|
|
67
|
+
return context.evaluate(sel, context, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue
|
|
74
68
|
} else {
|
|
75
69
|
return root.querySelector(sel)
|
|
76
70
|
}
|
|
77
71
|
}
|
|
78
72
|
|
|
79
|
-
export function findElements(context: Context, selector: Selector, parent: Element){
|
|
80
|
-
const eyesSelector =
|
|
73
|
+
export function findElements(context: Context, selector: Selector, parent: Element) {
|
|
74
|
+
const eyesSelector = selector as EyesSelector
|
|
81
75
|
const root = parent ?? context
|
|
82
76
|
const sel = typeof selector === 'string' ? selector : eyesSelector.selector
|
|
83
77
|
if (typeof selector !== 'string' && eyesSelector.type === 'xpath') {
|
|
84
|
-
const results = []
|
|
85
|
-
const queryResult = document.evaluate(sel, context,
|
|
86
|
-
null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
|
|
78
|
+
const results = []
|
|
79
|
+
const queryResult = document.evaluate(sel, context, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null)
|
|
87
80
|
|
|
88
81
|
for (let i = 0; i < queryResult.snapshotLength; i++) {
|
|
89
|
-
|
|
82
|
+
results.push(queryResult.snapshotItem(i))
|
|
90
83
|
}
|
|
91
|
-
return results
|
|
84
|
+
return results
|
|
92
85
|
} else {
|
|
93
86
|
return root.querySelectorAll(sel)
|
|
94
87
|
}
|
|
@@ -107,9 +100,8 @@ export function getCookies(): Array<any> {
|
|
|
107
100
|
return Cypress.automation('get:cookies', {})
|
|
108
101
|
}
|
|
109
102
|
|
|
110
|
-
|
|
111
103
|
// export function takeScreenshot(page: Driver): Promise<Buffer>;
|
|
112
104
|
|
|
113
105
|
// export function visit(page: Driver, url: string): Promise<void>; (??)
|
|
114
106
|
|
|
115
|
-
// export function isStaleElementError(err: any): boolean;
|
|
107
|
+
// export function isStaleElementError(err: any): boolean;
|
|
@@ -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
|