@applitools/eyes-cypress 3.29.0 → 3.30.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 CHANGED
@@ -12,6 +12,20 @@
12
12
 
13
13
 
14
14
 
15
+ ## 3.30.0 - 2023/3/19
16
+
17
+ ### Features
18
+ - Crop screenshot image base on account info
19
+ ### Bug fixes
20
+ - Fixed slowness during ufg tests
21
+ - Upgrade to core@v2
22
+
23
+ ## 3.29.1 - 2023/2/2
24
+
25
+ ### Features
26
+ ### Bug fixes
27
+ - update readme and add types folder to publish artifacts
28
+
15
29
  ## 3.29.0 - 2023/2/1
16
30
 
17
31
  ### Features
package/README.md CHANGED
@@ -31,19 +31,8 @@ The above command will add the necessary imports to your cypress `pluginsFile` a
31
31
 
32
32
  Eyes-Cypress acts as a [Cypress plugin](https://docs.cypress.io/guides/tooling/plugins-guide.html), so it should be configured as such.
33
33
  Unfortunately there's no easy way to do this automatically, so you need to manually:
34
- #### Cypress version < 10:
35
- Add the following code to your `pluginsFile`:
36
-
37
- **Important**: add this code **after** the definition of `module.exports`:
38
-
39
- ```js
40
- require('@applitools/eyes-cypress')(module)
41
- ```
42
-
43
- Normally, this is `cypress/plugins/index.js`. You can read more about it in Cypress' docs [here](https://docs.cypress.io/guides/references/configuration.html#Folders-Files).
44
- <br>
45
34
 
46
- #### Cypress version >= 10:
35
+ #### Cypress version >= 10:
47
36
 
48
37
  Add the following code to your:
49
38
 
@@ -60,6 +49,19 @@ module.exports = eyesPlugin(defineConfig({
60
49
  }
61
50
  }))
62
51
  ```
52
+ <br>
53
+
54
+ #### Cypress version < 10:
55
+ Add the following code to your `pluginsFile`:
56
+
57
+ **Important**: add this code **after** the definition of `module.exports`:
58
+
59
+ ```js
60
+ require('@applitools/eyes-cypress')(module)
61
+ ```
62
+
63
+ Normally, this is `cypress/plugins/index.js`. You can read more about it in Cypress' docs [here](https://docs.cypress.io/guides/references/configuration.html#Folders-Files).
64
+ <br>
63
65
 
64
66
  ##### `cypress.config.ts`
65
67
 
@@ -90,20 +92,40 @@ Normally, this is `cypress/support/index.js` for cypress version < 10 and `cypre
90
92
 
91
93
  ##### 3. (Optional) TypeScript configuration
92
94
 
95
+ For `typescript` use you must add the following code to your `tsconfig.json`:
96
+
97
+ ```json
98
+ {
99
+ ...
100
+ "compilerOptions": {
101
+ ...
102
+ "types": ["@applitools/eyes-cypress", "cypress", "node"]
103
+ "moduleResolution": "node" // or "node16"
104
+ ...
105
+ }
106
+ }
107
+ ```
108
+
93
109
  Eyes-Cypress ships with official type declarations for TypeScript. This allows you to add eyes commands to your TypeScript tests.
94
110
 
95
- Add this file to your project with either:
111
+ Add this file to your project using one of the following two options:
96
112
  1. Adding the path to your [tsconfig](https://www.typescriptlang.org/docs/handbook/tsconfig-json.html) file:
113
+
114
+ ```json
115
+ {
116
+ ...
117
+ "compilerOptions": {
118
+ ...
119
+ "types": ["@applitools/eyes-cypress", "cypress", "node"]
120
+ ...
121
+ }
122
+ }
123
+ ```
124
+
125
+ 2. Create `index.d.ts` file under `cypress/support` folder that contains:
97
126
  ```
98
- {
99
- "files": ["./node_modules/@applitools/eyes-cypress/index.d.ts"],
100
- ...
101
- }
127
+ import "@applitools/eyes-cypress"
102
128
  ```
103
- 2. Copying the file to to your [cypress/support/](https://docs.cypress.io/guides/core-concepts/writing-and-organizing-tests.html#Folder-Structure) dir:
104
- ```
105
- cp node_modules/@applitools/eyes-cypress/index.d.ts ./cypress/support/
106
- ```
107
129
  ### Applitools API key
108
130
 
109
131
  In order to authenticate via the Applitools server, you need to supply the Eyes-Cypress SDK with the API key you got from Applitools. Read more about how to obtain the API key [here](https://applitools.com/docs/topics/overview/obtain-api-key.html).
@@ -253,6 +275,7 @@ Applitools will take screenshots and perform the visual comparisons in the backg
253
275
  - [`visualGridOptions`](#visualgridoptions)
254
276
  - [`coded regions-regionId`](#regionId)
255
277
  - [`lazy loading`](#lazy-loading)
278
+ - [Density metrics](#density-metrics-densitymetrics)
256
279
  - [Close](#close)
257
280
  - [GetAllTestResults](#getalltestresults)
258
281
  - [deleteTestResults](#deletetestresults)
@@ -735,7 +758,7 @@ It's possible to have the SDK scroll the entire page (or a specific length of th
735
758
 
736
759
  ```js
737
760
  // lazy loads with sensible defaults
738
- cy.eyesCheckWindow(lazyload:{})
761
+ cy.eyesCheckWindow({lazyload:{}})
739
762
 
740
763
  // lazy loads with options specified
741
764
  cy.eyesCheckWindow({lazyLoad: {
@@ -745,6 +768,23 @@ cy.eyesCheckWindow({lazyLoad: {
745
768
  }})
746
769
  ```
747
770
 
771
+ ##### Density metrics (`densityMetrics`)
772
+
773
+ In order to set the density metrics for the screenshot, use the `densityMetrics` method. This method accepts a object value with the following properties:
774
+
775
+ - `xdpi` - The exact physical pixels per inch of the screen in the X dimension.
776
+ - `ydpi` - The exact physical pixels per inch of the screen in the Y dimension.
777
+ - `scaleRatio` - The scale ratio.
778
+
779
+ ```js
780
+ // set density metrics
781
+ cy.eyesCheckWindow({
782
+ densityMetrics:
783
+ xdpi: 100,
784
+ ydpi: 100,
785
+ scaleRatio: 1
786
+ })
787
+ ```
748
788
 
749
789
  #### Close
750
790
 
@@ -17,7 +17,7 @@ function makeGlobalRunHooks({ closeManager, closeBatches, closeUniversalServer }
17
17
  const summaries = await closeManager();
18
18
  let testResults;
19
19
  for (const summary of summaries) {
20
- testResults = summary.results.map(({ testResults }) => testResults);
20
+ testResults = summary.results.map(({ result }) => result);
21
21
  }
22
22
  if (!config.appliConfFile.dontCloseBatches) {
23
23
  await closeBatches({
@@ -28,7 +28,7 @@ function makeGlobalRunHooks({ closeManager, closeBatches, closeUniversalServer }
28
28
  });
29
29
  }
30
30
  if (config.appliConfFile.tapDirPath) {
31
- await handleTestResults_1.default.handleBatchResultsFile(testResults, {
31
+ handleTestResults_1.default.handleBatchResultsFile(testResults, {
32
32
  tapDirPath: config.appliConfFile.tapDirPath,
33
33
  tapFileName: config.appliConfFile.tapFileName,
34
34
  });
@@ -55,7 +55,7 @@ function makePluginExport({ startServer, eyesConfig }) {
55
55
  return pluginInitArgs;
56
56
  }
57
57
  return function getCloseServer() {
58
- return eyesServer.close();
58
+ return new Promise(res => eyesServer.close(() => res()));
59
59
  };
60
60
  async function setupNodeEvents(origOn, cypressConfig) {
61
61
  const { server, port, closeManager, closeBatches, closeUniversalServer } = await startServer();
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const webSocket_1 = __importDefault(require("./webSocket"));
7
- const eyes_universal_1 = require("@applitools/eyes-universal");
7
+ const core_1 = require("@applitools/core");
8
8
  const handleTestResults_1 = __importDefault(require("./handleTestResults"));
9
9
  const path_1 = __importDefault(require("path"));
10
10
  const fs_1 = __importDefault(require("fs"));
@@ -32,7 +32,7 @@ function makeStartServer({ logger }) {
32
32
  if ((0, semver_1.lt)(cypressVersion, '7.0.0')) {
33
33
  forkOptions.execPath = await (0, which_1.default)('node');
34
34
  }
35
- const { port: universalPort, close: closeUniversalServer } = await (0, eyes_universal_1.makeServerProcess)({
35
+ const { port: universalPort, close: closeUniversalServer } = await (0, core_1.makeCoreServerProcess)({
36
36
  idleTimeout: 0,
37
37
  shutdownMode: 'stdin',
38
38
  forkOptions,
@@ -101,14 +101,11 @@ function makeStartServer({ logger }) {
101
101
  closeUniversalServer,
102
102
  };
103
103
  function closeManager() {
104
- return Promise.all(managers.map(({ manager, socketWithUniversal }) => socketWithUniversal.request('EyesManager.closeManager', {
105
- manager,
106
- throwErr: false,
107
- })));
104
+ return Promise.all(managers.map(({ manager, socketWithUniversal }) => socketWithUniversal.request('EyesManager.getResults', { manager, settings: { throwErr: false } })));
108
105
  }
109
106
  function closeBatches(settings) {
110
107
  if (socketWithUniversal)
111
- return socketWithUniversal.request('Core.closeBatches', { settings }).catch((err) => {
108
+ return socketWithUniversal.request('Core.closeBatch', { settings }).catch((err) => {
112
109
  logger.log('@@@', err);
113
110
  });
114
111
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applitools/eyes-cypress",
3
- "version": "3.29.0",
3
+ "version": "3.30.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git://github.com/applitools/eyes.sdk.javascript1.git",
@@ -22,7 +22,8 @@
22
22
  "bin",
23
23
  "index.js",
24
24
  "commands.js",
25
- "index.d.ts"
25
+ "index.d.ts",
26
+ "types"
26
27
  ],
27
28
  "scripts": {
28
29
  "lint": "eslint \"**/*.{js,ts}\"",
@@ -44,7 +45,7 @@
44
45
  "cypress12": "./node_modules/cypress12/bin/cypress",
45
46
  "test:ts:run:12": "yarn cypress12 run --project ./test/e2e/ts --config-file ./cypress-12.config.ts",
46
47
  "test:ts:run": "yarn test:ts:run:legacy && yarn test:ts:run:9",
47
- "test:coverage": "yarn generate:tests && cd test/coverage/generic && yarn && unset APPLITOOLS_API_KEY && APPLITOOLS_BATCH_NAME='JS Coverage Tests: eyes-cypress' APPLITOOLS_BATCH_ID=$(uuidgen) npx cypress run",
48
+ "test:coverage": "yarn generate:tests && cd test/coverage/generic && yarn && APPLITOOLS_BATCH_NAME='JS Coverage Tests: eyes-cypress' APPLITOOLS_BATCH_ID=$(uuidgen) npx cypress run",
48
49
  "test:e2e": "mkdir -p test/fixtures/testAppCopies && mocha --no-timeouts 'test/e2e/**/*.test.js'",
49
50
  "test:components": "cd test/components && yarn && npx cypress run --component",
50
51
  "cypress": "cypress open --config-file test/fixtures/cypress-play.json",
@@ -57,7 +58,7 @@
57
58
  "deps": "bongo deps",
58
59
  "preversion": "yarn build && bongo preversion --skip-deps --verifyPendingChanges --skipVerifyInstalledVersions",
59
60
  "version": "bongo version --withPendingChanges",
60
- "postversion": "bongo postversion --skip-release-notification"
61
+ "postversion": "bongo postversion"
61
62
  },
62
63
  "husky": {
63
64
  "hooks": {
@@ -65,12 +66,11 @@
65
66
  }
66
67
  },
67
68
  "dependencies": {
68
- "@applitools/core": "1.4.6",
69
- "@applitools/eyes-api": "1.13.1",
70
- "@applitools/eyes-universal": "2.18.0",
69
+ "@applitools/core": "2.4.2",
70
+ "@applitools/eyes-api": "1.13.12",
71
71
  "@applitools/functional-commons": "1.6.0",
72
- "@applitools/logger": "1.1.43",
73
- "@applitools/utils": "1.3.28",
72
+ "@applitools/logger": "1.1.48",
73
+ "@applitools/utils": "1.3.32",
74
74
  "boxen": "5.1.2",
75
75
  "chalk": "3.0.0",
76
76
  "semver": "7.3.8",
@@ -79,20 +79,17 @@
79
79
  "ws": "8.5.0"
80
80
  },
81
81
  "devDependencies": {
82
- "@applitools/api-extractor": "^1.2.11",
83
- "@applitools/bongo": "^2.2.2",
84
- "@applitools/scripts": "1.2.0",
85
- "@applitools/sdk-coverage-tests": "^2.7.8",
82
+ "@applitools/api-extractor": "^1.2.12",
83
+ "@applitools/bongo": "^3.0.1",
84
+ "@applitools/sdk-coverage-tests": "^3.0.0",
86
85
  "@applitools/snaptdout": "1.0.1",
87
- "@applitools/test-server": "1.1.22",
88
- "@applitools/test-utils": "1.5.11",
86
+ "@applitools/test-server": "1.1.28",
87
+ "@applitools/test-utils": "1.5.14",
89
88
  "@types/node": "12",
90
89
  "@types/semver": "^7.3.13",
91
90
  "@types/uuid": "^9.0.0",
92
91
  "@types/which": "^2.0.1",
93
92
  "@types/ws": "^8.2.2",
94
- "@typescript-eslint/eslint-plugin": "^5.47.1",
95
- "@typescript-eslint/parser": "^5.47.1",
96
93
  "chai": "4.2.0",
97
94
  "chai-spies": "1.0.0",
98
95
  "cookie-parser": "1.4.4",
@@ -102,11 +99,7 @@
102
99
  "cypress12": "npm:cypress@^12.0.0",
103
100
  "cypress9": "npm:cypress@^9.0.0",
104
101
  "eslint": "8.10.0",
105
- "eslint-config-prettier": "^8.5.0",
106
- "eslint-plugin-mocha-no-only": "1.1.0",
107
- "eslint-plugin-no-only-tests": "^3.1.0",
108
- "eslint-plugin-node": "^11.1.0",
109
- "eslint-plugin-prettier": "^4.0.0",
102
+ "eslint-plugin-mocha-no-only": "1.1.1",
110
103
  "husky": "4.3.8",
111
104
  "lodash.omit": "4.5.0",
112
105
  "mocha": "8.0.1",
@@ -4,18 +4,31 @@ const spec = require('../../dist/browser/spec-driver')
4
4
  const Refer = require('./refer')
5
5
  const Socket = require('./socket')
6
6
  const {socketCommands} = require('./socketCommands')
7
- const {eyesOpenMapValues} = require('./eyesOpenMapping')
7
+ const {eyesOpenMapValues, eyesOpenToCheckMapValues} = require('./eyesOpenMapping')
8
8
  const {eyesCheckMapValues} = require('./eyesCheckMapping')
9
9
  const {TestResultsSummary} = require('@applitools/eyes-api')
10
10
  const refer = new Refer()
11
11
  const socket = new Socket()
12
12
  const throwErr = Cypress.config('failCypressOnDiff')
13
13
  socketCommands(socket, refer)
14
- let connectedToUniversal = false
15
14
 
16
15
  let manager,
17
16
  eyes,
18
- closePromiseArr = []
17
+ closePromiseArr = [],
18
+ _summary,
19
+ connectedToUniversal,
20
+ openToCheckSettingsArgs
21
+
22
+ async function getSummary() {
23
+ if (_summary) return _summary
24
+ await Promise.all(closePromiseArr)
25
+ _summary = socket.request('EyesManager.getResults', {manager, settings: {throwErr}}).catch(err => {
26
+ return {results: [{result: err.info.result}]}
27
+ })
28
+ _summary = await _summary
29
+
30
+ return _summary
31
+ }
19
32
 
20
33
  function getGlobalConfigProperty(prop) {
21
34
  const property = Cypress.config(prop)
@@ -34,8 +47,6 @@ Cypress.Commands.add('eyesGetAllTestResults', () => {
34
47
  isCurrentTestDisabled = false
35
48
  return
36
49
  }
37
- await Promise.all(closePromiseArr)
38
- const summary = await socket.request('EyesManager.closeManager', {manager, throwErr})
39
50
 
40
51
  const deleteTest = ({settings: {testId, batchId, secretToken}}) => {
41
52
  const {serverUrl, proxy, apiKey} = Cypress.config('appliConfFile')
@@ -50,9 +61,7 @@ Cypress.Commands.add('eyesGetAllTestResults', () => {
50
61
  },
51
62
  })
52
63
  }
53
- summary.results = summary.results.map(res => {
54
- return {...res, result: res.testResults, error: res.exception, renderer: res.browserInfo}
55
- })
64
+ const summary = await getSummary()
56
65
  return new TestResultsSummary({summary, deleteTest})
57
66
  })
58
67
  })
@@ -73,9 +82,9 @@ if (shouldUseBrowserHooks || Cypress.config('eyesFailCypressOnDiff')) {
73
82
  tapFileName: Cypress.config('appliConfFile').tapFileName,
74
83
  shouldCreateTapFile: shouldUseBrowserHooks,
75
84
  }
76
- await Promise.all(closePromiseArr)
77
- const summary = await socket.request('EyesManager.closeManager', {manager, throwErr})
78
- const testResults = summary.results.map(({testResults}) => testResults)
85
+
86
+ const summary = await getSummary()
87
+ const testResults = summary.results.map(({result}) => result)
79
88
  const message = await socket.request('Test.printTestResults', {testResults, resultConfig})
80
89
  if (
81
90
  !!getGlobalConfigProperty('eyesFailCypressOnDiff') &&
@@ -105,38 +114,37 @@ Cypress.Commands.add('eyesOpen', function (args = {}) {
105
114
 
106
115
  return cy.then({timeout: 86400000}, async () => {
107
116
  setRootContext()
108
- const driver = refer.ref(cy.state('window').document)
117
+ const target = refer.ref(cy.state('window').document)
109
118
 
110
119
  if (!connectedToUniversal) {
111
120
  socket.connect(`wss://localhost:${Cypress.config('eyesPort')}/eyes`)
112
121
  connectedToUniversal = true
113
- socket.emit('Core.makeSDK', {
114
- name: 'eyes.cypress',
115
- version: require('../../package.json').version,
116
- commands: Object.keys(spec).concat(['isSelector', 'isDriver', 'isElement']), // TODO fix spec.isSelector and spec.isDriver and spec.isElement in driver utils
122
+ socket.emit('Core.makeCore', {
123
+ agentId: `eyes.cypress/${require('../../package.json').version}`,
124
+ cwd: Cypress.config('projectRoot'),
125
+ spec: Object.keys(spec).concat(['isSelector', 'isDriver', 'isElement']), // TODO fix spec.isSelector and spec.isDriver and spec.isElement in driver
117
126
  })
118
127
 
119
128
  manager =
120
129
  manager ||
121
130
  (await socket.request(
122
131
  'Core.makeManager',
123
- Object.assign({}, {concurrency: Cypress.config('eyesTestConcurrency')}, {legacy: false, type: 'vg'}),
132
+ Object.assign({}, {concurrency: Cypress.config('eyesTestConcurrency')}, {type: 'ufg'}),
124
133
  ))
125
134
  }
126
135
 
127
136
  const appliConfFile = Cypress.config('appliConfFile')
128
- const config = eyesOpenMapValues({
137
+
138
+ openToCheckSettingsArgs = eyesOpenToCheckMapValues(args)
139
+
140
+ const settings = eyesOpenMapValues({
129
141
  args,
130
142
  appliConfFile,
131
143
  testName,
132
144
  shouldUseBrowserHooks,
133
- defaultBrowser: {
134
- width: Cypress.config('viewportWidth'),
135
- height: Cypress.config('viewportHeight'),
136
- name: 'chrome',
137
- },
138
145
  })
139
- eyes = await socket.request('EyesManager.openEyes', {manager, driver, config})
146
+
147
+ eyes = await socket.request('EyesManager.openEyes', {manager, target, settings})
140
148
  })
141
149
  })
142
150
 
@@ -145,16 +153,20 @@ Cypress.Commands.add('eyesCheckWindow', (args = {}) =>
145
153
  if (isCurrentTestDisabled) return
146
154
 
147
155
  setRootContext()
148
- const driver = refer.ref(cy.state('window').document)
156
+ const target = refer.ref(cy.state('window').document)
149
157
 
150
158
  Cypress.log({name: 'Eyes: check window'})
151
159
 
152
- const checkSettings = eyesCheckMapValues({args, refer})
160
+ const settings = eyesCheckMapValues({
161
+ args: {...openToCheckSettingsArgs, ...args},
162
+ refer,
163
+ appliConfFile: Cypress.config('appliConfFile'),
164
+ })
153
165
 
154
166
  return socket.request('Eyes.check', {
155
167
  eyes,
156
- settings: checkSettings,
157
- driver,
168
+ settings,
169
+ target,
158
170
  })
159
171
  }),
160
172
  )
@@ -169,11 +181,12 @@ Cypress.Commands.add('eyesClose', () => {
169
181
  return
170
182
  }
171
183
 
172
- // intentionally not returning the result in order to not wait on the close promise
173
- const p = socket.request('Eyes.close', {eyes, throwErr: false}).catch(err => {
184
+ // Eyes.close in core is not waiting on results anymore. So we should return it in order to await it
185
+ const p = socket.request('Eyes.close', {eyes}).catch(err => {
174
186
  console.log('Error in cy.eyesClose', err)
175
187
  })
176
188
  closePromiseArr.push(p)
189
+ return p
177
190
  })
178
191
  })
179
192
 
@@ -1,9 +1,12 @@
1
1
  /* global Node */
2
- function eyesCheckMapValues({args, refer}) {
2
+ function eyesCheckMapValues({openToCheckSettingsArgs, args, refer, appliConfFile}) {
3
3
  if (typeof args === `string`) {
4
4
  args = {tag: args}
5
5
  }
6
- const config = args // just did it for having less git changes at this moment
6
+ args = {...openToCheckSettingsArgs, ...args}
7
+ if (typeof args.waitBeforeCapture !== 'number') args.waitBeforeCapture = appliConfFile.waitBeforeCapture
8
+ let accessibilitySettings = args.accessibilitySettings || appliConfFile.accessibilityValidation
9
+
7
10
  const mappedValues = [
8
11
  'tag',
9
12
  'scriptHooks',
@@ -20,56 +23,75 @@ function eyesCheckMapValues({args, refer}) {
20
23
 
21
24
  let regionSettings = {}
22
25
  let shadowDomSettings = {}
26
+
27
+ let renderers = args.renderers || args.browser || appliConfFile.browser
28
+ if (renderers) {
29
+ if (Array.isArray(renderers)) {
30
+ for (const [index, value] of renderers.entries()) {
31
+ renderers[index] = fillDefaultBrowserName(value)
32
+ }
33
+ } else {
34
+ renderers = [fillDefaultBrowserName(renderers)]
35
+ }
36
+ }
37
+
23
38
  const checkSettings = {
24
- name: config.tag,
25
- hooks: config.scriptHooks,
26
- ignoreRegions: convertPaddedRegion(config.ignore),
27
- floatingRegions: convertFloatingRegion(config.floating),
28
- strictRegions: convertPaddedRegion(config.strict),
29
- layoutRegions: convertPaddedRegion(config.layout),
30
- contentRegions: convertPaddedRegion(config.content),
31
- accessibilityRegions: convertAccessabilityRegions(config.accessibility),
39
+ name: args.tag,
40
+ hooks: args.scriptHooks,
41
+ ignoreRegions: convertPaddedRegion(args.ignore),
42
+ floatingRegions: convertFloatingRegion(args.floating),
43
+ strictRegions: convertPaddedRegion(args.strict),
44
+ layoutRegions: convertPaddedRegion(args.layout),
45
+ contentRegions: convertPaddedRegion(args.content),
46
+ accessibilityRegions: convertAccessabilityRegions(args.accessibility),
47
+ renderers,
48
+ }
49
+ if (args.variationGroupId) {
50
+ checkSettings.userCommandId = args.variationGroupId
51
+ }
52
+ if (args.accessibilitySettings) {
53
+ checkSettings.accessibilitySettings = accessibilitySettings
32
54
  }
33
55
 
34
- if (config.target === 'region') {
35
- if (!Array.isArray(config.selector)) {
36
- if (config.element) {
37
- if (isHTMLElement(config.element)) {
56
+ if (args.target === 'region') {
57
+ if (!Array.isArray(args.selector)) {
58
+ if (args.element) {
59
+ if (isHTMLElement(args.element)) {
38
60
  regionSettings = {
39
- region: Object.assign(refer.ref(config.element), {type: 'element'}),
61
+ region: Object.assign(refer.ref(args.element), {type: 'element'}),
40
62
  }
41
63
  } else {
42
64
  // JQuery element
43
65
  regionSettings = {
44
- region: Object.assign(refer.ref(config.element[0]), {type: 'element'}),
66
+ region: Object.assign(refer.ref(args.element[0]), {type: 'element'}),
45
67
  }
46
68
  }
47
69
  } else if (
48
- config.region &&
49
- config.region.hasOwnProperty('top') &&
50
- config.region.hasOwnProperty('left') &&
51
- config.region.hasOwnProperty('width') &&
52
- config.region.hasOwnProperty('height')
70
+ args.region &&
71
+ args.region.hasOwnProperty('top') &&
72
+ args.region.hasOwnProperty('left') &&
73
+ args.region.hasOwnProperty('width') &&
74
+ args.region.hasOwnProperty('height')
53
75
  ) {
54
76
  regionSettings = {
55
77
  region: {
56
- y: config.region.top,
57
- x: config.region.left,
58
- width: config.region.width,
59
- height: config.region.height,
78
+ y: args.region.top,
79
+ x: args.region.left,
80
+ width: args.region.width,
81
+ height: args.region.height,
60
82
  },
61
83
  }
62
- } else if (!config.hasOwnProperty('selector')) {
84
+ } else if (!args.hasOwnProperty('selector')) {
63
85
  regionSettings = {
64
- region: config.region,
86
+ region: args.region,
65
87
  }
66
88
  } else {
67
89
  regionSettings = {
68
- region: config.selector,
90
+ region: args.selector,
69
91
  }
70
92
  }
71
93
  } else {
72
- const selectors = config.selector
94
+ const selectors = args.selector
73
95
  for (let i = selectors.length - 1; i > -1; i--) {
74
96
  if (i === selectors.length - 1) {
75
97
  shadowDomSettings['shadow'] = selectors[i].selector
@@ -88,12 +110,12 @@ function eyesCheckMapValues({args, refer}) {
88
110
  }
89
111
 
90
112
  for (const val of mappedValues) {
91
- if (config.hasOwnProperty(val)) {
92
- delete config[val]
113
+ if (args.hasOwnProperty(val)) {
114
+ delete args[val]
93
115
  }
94
116
  }
95
117
 
96
- return Object.assign({}, checkSettings, regionSettings, config)
118
+ return Object.assign({}, checkSettings, regionSettings, args)
97
119
 
98
120
  // #region helper functions
99
121
 
@@ -176,10 +198,12 @@ function eyesCheckMapValues({args, refer}) {
176
198
 
177
199
  for (const region of floatingRegions) {
178
200
  const floatingRegion = {
179
- maxDownOffset: region.maxDownOffset || 0,
180
- maxLeftOffset: region.maxLeftOffset || 0,
181
- maxUpOffset: region.maxUpOffset || 0,
182
- maxRightOffset: region.maxRightOffset || 0,
201
+ offset: {
202
+ bottom: region.maxDownOffset || 0,
203
+ left: region.maxLeftOffset || 0,
204
+ top: region.maxUpOffset || 0,
205
+ right: region.maxRightOffset || 0,
206
+ },
183
207
  }
184
208
  if (region.hasOwnProperty('selector')) {
185
209
  floatingRegion.region = region.selector
@@ -191,7 +215,7 @@ function eyesCheckMapValues({args, refer}) {
191
215
  floating.push(Object.assign({}, region, floatingRegion, {region: element}))
192
216
  }
193
217
  } else if (region.hasOwnProperty('region')) {
194
- floating.push(region)
218
+ floating.push({offset: floatingRegion.offset, ...region})
195
219
  } else {
196
220
  floatingRegion.region = {
197
221
  y: region.top,
@@ -233,4 +257,18 @@ function isHTMLElement(element) {
233
257
  return element.nodeType && element.nodeType === Node.ELEMENT_NODE
234
258
  }
235
259
 
260
+ function fillDefaultBrowserName(browser) {
261
+ if (!browser.iosDeviceInfo && !browser.chromeEmulationInfo) {
262
+ if (!browser.name) {
263
+ browser.name = 'chrome'
264
+ }
265
+ if (browser.deviceName) {
266
+ browser = {chromeEmulationInfo: browser}
267
+ }
268
+ return browser
269
+ } else {
270
+ return browser
271
+ }
272
+ }
273
+
236
274
  module.exports = {eyesCheckMapValues}