@applitools/eyes-cypress 3.44.8 → 3.44.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,62 @@
1
1
  # Changelog
2
2
 
3
+ ## [3.44.9](https://github.com/Applitools-Dev/sdk/compare/js/eyes-cypress@3.44.8...js/eyes-cypress@3.44.9) (2024-09-16)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * stale layout breakpoints elements ([#2479](https://github.com/Applitools-Dev/sdk/issues/2479)) ([f5e4b5a](https://github.com/Applitools-Dev/sdk/commit/f5e4b5ac8077b8c4b7ba67a38c4e58050a55ce75))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * @applitools/snippets bumped to 2.5.0
14
+ #### Features
15
+
16
+ * add playwright fixture ([#2412](https://github.com/Applitools-Dev/sdk/issues/2412)) ([0632e93](https://github.com/Applitools-Dev/sdk/commit/0632e93dd7f53029a8c5f4230d22a05abf5fefd4))
17
+
18
+
19
+ #### Bug Fixes
20
+
21
+ * stale layout breakpoints elements ([#2479](https://github.com/Applitools-Dev/sdk/issues/2479)) ([f5e4b5a](https://github.com/Applitools-Dev/sdk/commit/f5e4b5ac8077b8c4b7ba67a38c4e58050a55ce75))
22
+ * @applitools/dom-capture bumped to 11.5.0
23
+ #### Features
24
+
25
+ * ability to capture element properties ([#2525](https://github.com/Applitools-Dev/sdk/issues/2525)) ([ab35e1d](https://github.com/Applitools-Dev/sdk/commit/ab35e1dc929ba4bd82e99081527b277c8090f1e0))
26
+ * @applitools/driver bumped to 1.19.1
27
+ #### Bug Fixes
28
+
29
+ * stale layout breakpoints elements ([#2479](https://github.com/Applitools-Dev/sdk/issues/2479)) ([f5e4b5a](https://github.com/Applitools-Dev/sdk/commit/f5e4b5ac8077b8c4b7ba67a38c4e58050a55ce75))
30
+
31
+
32
+
33
+ * @applitools/spec-driver-webdriver bumped to 1.1.13
34
+
35
+ * @applitools/spec-driver-selenium bumped to 1.5.84
36
+
37
+ * @applitools/spec-driver-puppeteer bumped to 1.4.13
38
+
39
+ * @applitools/screenshoter bumped to 3.8.37
40
+
41
+ * @applitools/nml-client bumped to 1.8.11
42
+
43
+ * @applitools/ec-client bumped to 1.9.5
44
+
45
+ * @applitools/core bumped to 4.19.0
46
+ #### Features
47
+
48
+ * allow passing arguments to dom-capture from core ([#2531](https://github.com/Applitools-Dev/sdk/issues/2531)) ([9cfc9a5](https://github.com/Applitools-Dev/sdk/commit/9cfc9a5b5d6650afd1e7daf2714d6779a7dc2724))
49
+
50
+
51
+ #### Bug Fixes
52
+
53
+ * stale layout breakpoints elements ([#2479](https://github.com/Applitools-Dev/sdk/issues/2479)) ([f5e4b5a](https://github.com/Applitools-Dev/sdk/commit/f5e4b5ac8077b8c4b7ba67a38c4e58050a55ce75))
54
+
55
+
56
+
57
+ * @applitools/eyes bumped to 1.22.3
58
+
59
+
3
60
  ## [3.44.8](https://github.com/Applitools-Dev/sdk/compare/js/eyes-cypress@3.44.7...js/eyes-cypress@3.44.8) (2024-09-10)
4
61
 
5
62
 
@@ -11,7 +11,12 @@ function executeScript(context, script, arg) {
11
11
  scriptToExecute = prepScirpt.concat(' return func(arg)');
12
12
  }
13
13
  const executor = new context.defaultView.Function('arg', scriptToExecute);
14
- return executor(arg);
14
+ try {
15
+ return executor(arg);
16
+ }
17
+ catch (e) {
18
+ throw new Error(`Failed to execute script: ${e}`); // stringifiying prevents [object Object] errors
19
+ }
15
20
  }
16
21
  exports.executeScript = executeScript;
17
22
  function mainContext() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applitools/eyes-cypress",
3
- "version": "3.44.8",
3
+ "version": "3.44.9",
4
4
  "homepage": "https://applitools.com/docs/api-ref/sdk-api/cypress/",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "main": "./index.js",
@@ -22,7 +22,7 @@
22
22
  "build": "run --top-level tspc --project ./tsconfig.build.json",
23
23
  "generate:tests": "NODE_OPTIONS='--experimental-import-meta-resolve --experimental-loader=@applitools/generic/dist/code-loader.js' generic ./test/generic/config.mjs",
24
24
  "test": "yarn test:unit && yarn test:it && yarn test:ts:compile && yarn test:setup && yarn test:components && yarn test:e2e",
25
- "test:unit": "run --top-level mocha --no-timeouts 'test/unit/**/*.test.js'",
25
+ "test:unit": "run --top-level mocha --no-timeouts 'test/unit/**/*.test.{js,ts}'",
26
26
  "test:it": "run --top-level mocha --no-timeouts 'test/it/**/*.test.js'",
27
27
  "test:setup": "run --top-level mocha --no-timeouts 'test/setup/**/*.test.js'",
28
28
  "test:ts": "yarn test:ts:compile && yarn test:ts:run",
@@ -54,7 +54,7 @@
54
54
  "setup": "run --top-level xvfb:setup"
55
55
  },
56
56
  "dependencies": {
57
- "@applitools/core": "4.18.2",
57
+ "@applitools/core": "4.19.0",
58
58
  "@applitools/eyes": "1.22.2",
59
59
  "@applitools/functional-commons": "1.6.0",
60
60
  "@applitools/logger": "2.0.18",
@@ -0,0 +1,28 @@
1
+ const derefArgsCallStack = []
2
+ function derefArgs(refer, arg) {
3
+ if (derefArgsCallStack.includes(arg)) return arg // prevent circular reference
4
+ try {
5
+ derefArgsCallStack.push(arg)
6
+ if (refer.isRef(arg)) return refer.deref(arg)
7
+ else if (Array.isArray(arg)) {
8
+ const derefArg = []
9
+ for (const argument of arg) {
10
+ derefArg.push(derefArgs(refer, argument))
11
+ }
12
+ return derefArg
13
+ } else if (typeof arg === 'object') {
14
+ const derefArg = {}
15
+ for (const [key, value] of Object.entries(arg)) {
16
+ derefArg[key] = derefArgs(refer, value)
17
+ }
18
+ return derefArg
19
+ }
20
+ return arg
21
+ } finally {
22
+ derefArgsCallStack.pop()
23
+ }
24
+ }
25
+
26
+ module.exports = {
27
+ derefArgs,
28
+ }
@@ -3,16 +3,28 @@
3
3
  const uuid = require('uuid')
4
4
  const REF_ID = 'applitools-ref-id'
5
5
 
6
+ // type RefType = 'cypress-driver' | 'element' | 'context' | 'driver'
7
+
8
+ // type Ref = {
9
+ // [REF_ID]: string
10
+ // type?: RefType
11
+ // }
12
+
6
13
  class Refer {
14
+ // store: Map<string, any>
15
+ // relation: Map<string, Set<Ref>>
16
+
7
17
  constructor() {
8
18
  this.store = new Map()
9
19
  this.relation = new Map()
10
20
  }
11
21
 
22
+ // isRef(ref: any): ref is Ref {
12
23
  isRef(ref) {
13
24
  return Boolean(ref && ref[REF_ID])
14
25
  }
15
26
 
27
+ // check(value: any): RefType | undefined {
16
28
  check(value) {
17
29
  if (!value) return
18
30
  if (value === '__CYPRESS_DRIVER__') {
@@ -26,6 +38,7 @@ class Refer {
26
38
  }
27
39
  }
28
40
 
41
+ // ref(value: any, parentRef?: Ref) {
29
42
  ref(value, parentRef) {
30
43
  const refType = this.check(value)
31
44
  if (refType) {
@@ -1,8 +1,9 @@
1
1
  const spec = require('../../dist/browser/spec-driver')
2
+ const {derefArgs} = require('./derefArgs')
2
3
 
3
4
  function socketCommands(socket, refer) {
4
5
  socket.command('Driver.executeScript', ({context, script, arg = []}) => {
5
- const res = spec.executeScript(refer.deref(context), script, derefArgs(arg))
6
+ const res = spec.executeScript(refer.deref(context), script, derefArgs(refer, arg))
6
7
  return res ? refer.ref(res) : res
7
8
  })
8
9
 
@@ -48,29 +49,6 @@ function socketCommands(socket, refer) {
48
49
  socket.command('Driver.reload', async () => {
49
50
  await spec.reload()
50
51
  })
51
-
52
- // utils
53
-
54
- function derefArgs(arg) {
55
- const derefArg = []
56
- if (Array.isArray(arg)) {
57
- for (const argument of arg) {
58
- if (Array.isArray(argument)) {
59
- derefArg.push(derefArgs(argument))
60
- } else {
61
- derefArg.push(refer.deref(argument))
62
- }
63
- }
64
- return derefArg
65
- } else if (typeof arg === 'object') {
66
- for (const [key, value] of Object.entries(arg)) {
67
- derefArg[key] = refer.deref(value)
68
- }
69
- return derefArg
70
- } else {
71
- return arg
72
- }
73
- }
74
52
  }
75
53
 
76
54
  module.exports = {socketCommands}
@@ -13,7 +13,11 @@ export function executeScript(context: Context, script: string, arg: any): any {
13
13
  }
14
14
 
15
15
  const executor = new context.defaultView.Function('arg', scriptToExecute)
16
- return executor(arg)
16
+ try {
17
+ return executor(arg)
18
+ } catch (e) {
19
+ throw new Error(`Failed to execute script: ${e}`) // stringifiying prevents [object Object] errors
20
+ }
17
21
  }
18
22
 
19
23
  export function mainContext(): Context {