@applitools/eyes-cypress 3.28.0 → 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.
@@ -1,22 +1,22 @@
1
1
  const batchPropertiesRetriever = (args, appliConfFile) => {
2
- return function(prop, nestedProp) {
3
- nestedProp = nestedProp || prop;
2
+ return function (prop, nestedProp) {
3
+ nestedProp = nestedProp || prop
4
4
  if (args.hasOwnProperty(prop)) {
5
- return args[prop];
5
+ return args[prop]
6
6
  } else if (args.batch && args.batch.hasOwnProperty(nestedProp)) {
7
- return args.batch[nestedProp];
7
+ return args.batch[nestedProp]
8
8
  } else if (appliConfFile.hasOwnProperty(prop)) {
9
- return appliConfFile[prop];
9
+ return appliConfFile[prop]
10
10
  } else if (appliConfFile.batch && appliConfFile.batch.hasOwnProperty(nestedProp)) {
11
- return appliConfFile.batch[nestedProp];
11
+ return appliConfFile.batch[nestedProp]
12
12
  }
13
- return undefined;
14
- };
15
- };
13
+ return undefined
14
+ }
15
+ }
16
16
  function eyesOpenMapValues({args, appliConfFile, testName, shouldUseBrowserHooks}) {
17
- let browsersInfo = args.browser || appliConfFile.browser;
18
- let accessibilitySettings = args.accessibilityValidation || appliConfFile.accessibilityValidation;
19
- const batchProperties = batchPropertiesRetriever(args, appliConfFile);
17
+ let browsersInfo = args.browser || appliConfFile.browser
18
+ let accessibilitySettings = args.accessibilityValidation || appliConfFile.accessibilityValidation
19
+ const batchProperties = batchPropertiesRetriever(args, appliConfFile)
20
20
  const batch = {
21
21
  id: batchProperties('batchId', 'id'),
22
22
  name: batchProperties('batchName', 'name'),
@@ -25,10 +25,10 @@ function eyesOpenMapValues({args, appliConfFile, testName, shouldUseBrowserHooks
25
25
  properties:
26
26
  (args.batch ? args.batch.properties : undefined) ||
27
27
  (appliConfFile.batch ? appliConfFile.batch.properties : undefined),
28
- };
28
+ }
29
29
  for (let prop in batch) {
30
30
  if (typeof batch[prop] === 'undefined') {
31
- delete batch[prop];
31
+ delete batch[prop]
32
32
  }
33
33
  }
34
34
 
@@ -43,15 +43,15 @@ function eyesOpenMapValues({args, appliConfFile, testName, shouldUseBrowserHooks
43
43
  'batchName',
44
44
  'batchId',
45
45
  'batchSequenceName',
46
- ];
46
+ ]
47
47
 
48
48
  if (browsersInfo) {
49
49
  if (Array.isArray(browsersInfo)) {
50
50
  for (const [index, value] of browsersInfo.entries()) {
51
- browsersInfo[index] = fillDefaultBrowserName(value);
51
+ browsersInfo[index] = fillDefaultBrowserName(value)
52
52
  }
53
53
  } else {
54
- browsersInfo = [fillDefaultBrowserName(browsersInfo)];
54
+ browsersInfo = [fillDefaultBrowserName(browsersInfo)]
55
55
  }
56
56
  }
57
57
 
@@ -62,15 +62,15 @@ function eyesOpenMapValues({args, appliConfFile, testName, shouldUseBrowserHooks
62
62
  useDom: args.useDom || appliConfFile.useDom,
63
63
  enablePatterns: args.enablePatterns || appliConfFile.enablePatterns,
64
64
  ignoreDisplacements: args.ignoreDisplacements || appliConfFile.ignoreDisplacements,
65
- };
65
+ }
66
66
 
67
- const appliConfFileCopy = {...appliConfFile};
67
+ const appliConfFileCopy = {...appliConfFile}
68
68
  for (const val of mappedValues) {
69
69
  if (args.hasOwnProperty(val)) {
70
- delete args[val];
70
+ delete args[val]
71
71
  }
72
72
  if (appliConfFileCopy.hasOwnProperty(val)) {
73
- delete appliConfFileCopy[val];
73
+ delete appliConfFileCopy[val]
74
74
  }
75
75
  }
76
76
 
@@ -79,27 +79,23 @@ function eyesOpenMapValues({args, appliConfFile, testName, shouldUseBrowserHooks
79
79
  browsersInfo,
80
80
  defaultMatchSettings,
81
81
  batch,
82
- };
82
+ }
83
83
 
84
- return Object.assign(
85
- {testName, dontCloseBatches: !shouldUseBrowserHooks},
86
- appliConfFileCopy,
87
- mappedArgs,
88
- );
84
+ return Object.assign({testName, dontCloseBatches: !shouldUseBrowserHooks}, appliConfFileCopy, mappedArgs)
89
85
  }
90
86
 
91
87
  function fillDefaultBrowserName(browser) {
92
88
  if (!browser.iosDeviceInfo && !browser.chromeEmulationInfo) {
93
89
  if (!browser.name) {
94
- browser.name = 'chrome';
90
+ browser.name = 'chrome'
95
91
  }
96
92
  if (browser.deviceName) {
97
- browser = {chromeEmulationInfo: browser};
93
+ browser = {chromeEmulationInfo: browser}
98
94
  }
99
- return browser;
95
+ return browser
100
96
  } else {
101
- return browser;
97
+ return browser
102
98
  }
103
99
  }
104
100
 
105
- module.exports = {eyesOpenMapValues};
101
+ module.exports = {eyesOpenMapValues}
@@ -1,18 +1,13 @@
1
- 'use strict';
1
+ 'use strict'
2
2
 
3
3
  function makeSend(port, fetch) {
4
- return function send({
5
- command,
6
- data,
7
- method = 'POST',
8
- headers = {'Content-Type': 'application/json'},
9
- }) {
4
+ return function send({command, data, method = 'POST', headers = {'Content-Type': 'application/json'}}) {
10
5
  return fetch(`https://localhost:${port}/eyes/${command}`, {
11
6
  method,
12
7
  body: headers['Content-Type'] === 'application/json' ? JSON.stringify(data) : data,
13
8
  headers,
14
- });
15
- };
9
+ })
10
+ }
16
11
  }
17
12
 
18
- module.exports = makeSend;
13
+ module.exports = makeSend
@@ -1,70 +1,70 @@
1
1
  /* global Node */
2
2
 
3
- const uuid = require('uuid');
4
- const REF_ID = 'applitools-ref-id';
3
+ const uuid = require('uuid')
4
+ const REF_ID = 'applitools-ref-id'
5
5
 
6
6
  class Refer {
7
7
  constructor() {
8
- this.store = new Map();
9
- this.relation = new Map();
8
+ this.store = new Map()
9
+ this.relation = new Map()
10
10
  }
11
11
 
12
12
  isRef(ref) {
13
- return Boolean(ref && ref[REF_ID]);
13
+ return Boolean(ref && ref[REF_ID])
14
14
  }
15
15
 
16
16
  check(value) {
17
- if (!value) return;
17
+ if (!value) return
18
18
  if (value.nodeType === Node.ELEMENT_NODE) {
19
- return 'element';
19
+ return 'element'
20
20
  } else if (value.nodeType === Node.DOCUMENT_NODE || value.ownerDocument) {
21
- return 'context';
21
+ return 'context'
22
22
  } else if (value.constructor && value.constructor.name === 'Window') {
23
- return 'driver';
23
+ return 'driver'
24
24
  }
25
25
  }
26
26
 
27
27
  ref(value, parentRef) {
28
- const refType = this.check(value);
28
+ const refType = this.check(value)
29
29
  if (refType) {
30
- const ref = uuid.v4();
31
- this.store.set(ref, value);
30
+ const ref = uuid.v4()
31
+ this.store.set(ref, value)
32
32
  if (parentRef) {
33
- let childRefs = this.relation.get(parentRef[REF_ID]);
33
+ let childRefs = this.relation.get(parentRef[REF_ID])
34
34
  if (!childRefs) {
35
- childRefs = new Set();
36
- this.relation.set(parentRef[REF_ID], childRefs);
35
+ childRefs = new Set()
36
+ this.relation.set(parentRef[REF_ID], childRefs)
37
37
  }
38
- childRefs.add({[REF_ID]: ref});
38
+ childRefs.add({[REF_ID]: ref})
39
39
  }
40
- return {[REF_ID]: ref, type: refType};
40
+ return {[REF_ID]: ref, type: refType}
41
41
  } else if (Array.isArray(value)) {
42
- return value.map(value => this.ref(value, parentRef));
42
+ return value.map(value => this.ref(value, parentRef))
43
43
  } else if (typeof value === 'object' && value !== null) {
44
44
  return Object.entries(value).reduce((obj, [key, value]) => {
45
- return Object.assign(obj, {[key]: this.ref(value, parentRef)});
46
- }, {});
45
+ return Object.assign(obj, {[key]: this.ref(value, parentRef)})
46
+ }, {})
47
47
  } else {
48
- return value;
48
+ return value
49
49
  }
50
50
  }
51
51
 
52
52
  deref(ref) {
53
53
  if (this.isRef(ref)) {
54
- return this.store.get(ref[REF_ID]);
54
+ return this.store.get(ref[REF_ID])
55
55
  } else {
56
- return ref;
56
+ return ref
57
57
  }
58
58
  }
59
59
 
60
60
  destroy(ref) {
61
- if (!this.isRef(ref)) return;
62
- const childRefs = this.relation.get(ref[REF_ID]);
61
+ if (!this.isRef(ref)) return
62
+ const childRefs = this.relation.get(ref[REF_ID])
63
63
  if (childRefs) {
64
- childRefs.forEach(childRef => this.destroy(childRef));
64
+ childRefs.forEach(childRef => this.destroy(childRef))
65
65
  }
66
- this.store.delete(ref[REF_ID]);
66
+ this.store.delete(ref[REF_ID])
67
67
  }
68
68
  }
69
69
 
70
- module.exports = Refer;
70
+ module.exports = Refer
@@ -1,4 +1,4 @@
1
- 'use strict';
1
+ 'use strict'
2
2
 
3
3
  function makeSendRequest(send) {
4
4
  return function sendRequest(args) {
@@ -6,11 +6,11 @@ function makeSendRequest(send) {
6
6
  .then(resp => resp.json())
7
7
  .then(body => {
8
8
  if (!body.success) {
9
- throw new Error(body.error);
9
+ throw new Error(body.error)
10
10
  }
11
- return body.result;
12
- });
13
- };
11
+ return body.result
12
+ })
13
+ }
14
14
  }
15
15
 
16
- module.exports = makeSendRequest;
16
+ module.exports = makeSendRequest
@@ -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
- typeof type === 'string' ? {name: type, payload} : {name: type.name, key: type.key, payload};
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
- /* global Node */
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
- refer.deref(context),
31
- spec.transformSelector(selector),
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
- refer.deref(context),
39
- spec.transformSelector(selector),
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}