@applitools/core 4.32.2 → 4.34.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
@@ -1,5 +1,99 @@
1
1
  # Changelog
2
2
 
3
+ ## [4.34.0](https://github.com/Applitools-Dev/sdk/compare/js/core@4.33.0...js/core@4.34.0) (2025-03-30)
4
+
5
+
6
+ ### Features
7
+
8
+ * allow sending callback functions to waitBeforeCapture ([#2780](https://github.com/Applitools-Dev/sdk/issues/2780)) ([4caa2e8](https://github.com/Applitools-Dev/sdk/commit/4caa2e8ae055d3dd48164eeceaa4c691eeadcdd4))
9
+ * offline results state granularity ([#2872](https://github.com/Applitools-Dev/sdk/issues/2872)) ([c5f6e4e](https://github.com/Applitools-Dev/sdk/commit/c5f6e4ed87c4855704ce1a6c568393a35b677c1d))
10
+
11
+
12
+ ### Bug Fixes
13
+
14
+ * reject openCheckAndClose on request failures ([#2870](https://github.com/Applitools-Dev/sdk/issues/2870)) ([1d12d60](https://github.com/Applitools-Dev/sdk/commit/1d12d60991e8f222002273d5447702158f1cba84))
15
+
16
+
17
+ ### Dependencies
18
+
19
+ * @applitools/utils bumped to 1.8.0
20
+ #### Features
21
+
22
+ * allow sending callback functions to waitBeforeCapture ([#2780](https://github.com/Applitools-Dev/sdk/issues/2780)) ([4caa2e8](https://github.com/Applitools-Dev/sdk/commit/4caa2e8ae055d3dd48164eeceaa4c691eeadcdd4))
23
+ * @applitools/dom-snapshot bumped to 4.11.17
24
+ #### Bug Fixes
25
+
26
+ * input range value render issue - add input range to need map list ([#2866](https://github.com/Applitools-Dev/sdk/issues/2866)) ([6b3c113](https://github.com/Applitools-Dev/sdk/commit/6b3c113ab3068fc89b3d3917a12fc51bad66ca97))
27
+
28
+
29
+
30
+ * @applitools/socket bumped to 1.2.3
31
+
32
+ * @applitools/driver bumped to 1.21.0
33
+ #### Features
34
+
35
+ * allow sending callback functions to waitBeforeCapture ([#2780](https://github.com/Applitools-Dev/sdk/issues/2780)) ([4caa2e8](https://github.com/Applitools-Dev/sdk/commit/4caa2e8ae055d3dd48164eeceaa4c691eeadcdd4))
36
+
37
+
38
+
39
+ * @applitools/screenshoter bumped to 3.11.0
40
+ #### Features
41
+
42
+ * allow sending callback functions to waitBeforeCapture ([#2780](https://github.com/Applitools-Dev/sdk/issues/2780)) ([4caa2e8](https://github.com/Applitools-Dev/sdk/commit/4caa2e8ae055d3dd48164eeceaa4c691eeadcdd4))
43
+
44
+
45
+
46
+ * @applitools/logger bumped to 2.1.2
47
+
48
+ * @applitools/req bumped to 1.7.9
49
+
50
+ * @applitools/image bumped to 1.1.18
51
+
52
+ * @applitools/dom-capture bumped to 11.5.5
53
+
54
+ * @applitools/spec-driver-webdriver bumped to 1.2.1
55
+
56
+ * @applitools/spec-driver-selenium bumped to 1.5.97
57
+
58
+ * @applitools/spec-driver-puppeteer bumped to 1.4.26
59
+
60
+ * @applitools/nml-client bumped to 1.8.27
61
+
62
+ * @applitools/tunnel-client bumped to 1.6.4
63
+
64
+ * @applitools/ufg-client bumped to 1.16.8
65
+
66
+ * @applitools/core-base bumped to 1.22.3
67
+ #### Bug Fixes
68
+
69
+ * reject openCheckAndClose on request failures ([#2870](https://github.com/Applitools-Dev/sdk/issues/2870)) ([1d12d60](https://github.com/Applitools-Dev/sdk/commit/1d12d60991e8f222002273d5447702158f1cba84))
70
+
71
+
72
+
73
+ * @applitools/ec-client bumped to 1.10.7
74
+
75
+
76
+ ## [4.33.0](https://github.com/Applitools-Dev/sdk/compare/js/core@4.32.2...js/core@4.33.0) (2025-03-13)
77
+
78
+
79
+ ### Features
80
+
81
+ * support HTTPS_PROXY and HTTP_PROXY environment variables ([#2795](https://github.com/Applitools-Dev/sdk/issues/2795)) ([226ae08](https://github.com/Applitools-Dev/sdk/commit/226ae08627381a1212df8b938c6576e82c777914))
82
+
83
+
84
+ ### Dependencies
85
+
86
+ * @applitools/spec-driver-webdriver bumped to 1.2.0
87
+ #### Features
88
+
89
+ * support HTTPS_PROXY and HTTP_PROXY environment variables ([#2795](https://github.com/Applitools-Dev/sdk/issues/2795)) ([226ae08](https://github.com/Applitools-Dev/sdk/commit/226ae08627381a1212df8b938c6576e82c777914))
90
+ * @applitools/screenshoter bumped to 3.10.7
91
+
92
+ * @applitools/nml-client bumped to 1.8.26
93
+
94
+ * @applitools/ec-client bumped to 1.10.6
95
+
96
+
3
97
  ## [4.32.2](https://github.com/Applitools-Dev/sdk/compare/js/core@4.32.1...js/core@4.32.2) (2025-03-06)
4
98
 
5
99
 
@@ -43,7 +43,15 @@ async function takeScreenshot({ driver, settings, logger, }) {
43
43
  hideCaret: settings.hideCaret,
44
44
  scrollingMode: (_c = (_b = settings.stitchMode) === null || _b === void 0 ? void 0 : _b.toLowerCase()) !== null && _c !== void 0 ? _c : 'scroll',
45
45
  overlap: settings.overlap,
46
- wait: settings.waitBeforeCapture,
46
+ wait: async () => {
47
+ var _a;
48
+ if (typeof settings.waitBeforeCapture === 'number') {
49
+ await utils.general.sleep(settings.waitBeforeCapture);
50
+ }
51
+ else if (settings.waitBeforeCapture) {
52
+ await ((_a = driver.executeUserFunction) === null || _a === void 0 ? void 0 : _a.call(driver, settings.waitBeforeCapture));
53
+ }
54
+ },
47
55
  framed: environment.isNative,
48
56
  lazyLoad: settings.lazyLoad,
49
57
  stabilization: settings.normalization && {
@@ -127,6 +127,9 @@ function makeCheckAndClose({ eyes, target: defaultTarget, environments: defaultE
127
127
  settings: { ...eyes.test.eyesServer, supportedEnvironmentsUrl: eyes.test.supportedEnvironmentsUrl },
128
128
  logger,
129
129
  });
130
+ if (typeof settings.waitBeforeCapture === 'function') {
131
+ throw new Error('providing functions to waitBeforeCapture is not supported in NML - please use a number instead');
132
+ }
130
133
  const screenshots = await nmlClient.takeScreenshots({
131
134
  settings: {
132
135
  environments: uniqueEnvironments,
@@ -324,6 +324,9 @@ async function takeNMLScreenshot({ driver, settings, environments, logger, eyes,
324
324
  },
325
325
  });
326
326
  const calculate = elementReferences.calculate;
327
+ if (typeof settings.waitBeforeCapture === 'function') {
328
+ throw new Error('providing functions to waitBeforeCapture is not supported in NML - please use a number instead');
329
+ }
327
330
  const screenshots = await nmlClient.takeScreenshots({
328
331
  settings: {
329
332
  environments: environments,
@@ -77,7 +77,10 @@ async function runOfflineSnapshots(options) {
77
77
  totalTime: Date.now() - startTime,
78
78
  jsonFilePath: options.jsonFilePath,
79
79
  });
80
- if (!isSuccess && options.failOnDiff) {
80
+ if (!isSuccess.onErrors && options.failOnError) {
81
+ throw new Error(outputStr);
82
+ }
83
+ else if (!isSuccess.onDiffs && options.failOnDiff) {
81
84
  throw new Error(outputStr);
82
85
  }
83
86
  else {
@@ -155,7 +158,11 @@ async function runOfflineSnapshots(options) {
155
158
  await eyes.close({ settings: closeSettings });
156
159
  }
157
160
  else {
158
- await eyes.abort();
161
+ await eyes.abort({
162
+ settings: {
163
+ reason: 'internal',
164
+ },
165
+ });
159
166
  }
160
167
  logger.log('done running test', testPath);
161
168
  return { batchId: openSettings.batch.id, results: (await eyes.getResults({ logger }))[0] };
@@ -236,7 +243,7 @@ exports.runOfflineSnapshots = runOfflineSnapshots;
236
243
  function uniq(arr) {
237
244
  return [...new Set(arr)];
238
245
  }
239
- function processResults({ testResults, totalTime, saveNewTests = true, failOnDiff = true, jsonFilePath, }) {
246
+ function processResults({ testResults, totalTime, saveNewTests = true, jsonFilePath, }) {
240
247
  let outputStr = '\n';
241
248
  const pluralize = utils.general.pluralize;
242
249
  const testResultsWithErrors = testResults.filter(r => r && r.reason);
@@ -319,16 +326,9 @@ function processResults({ testResults, totalTime, saveNewTests = true, failOnDif
319
326
  // if (Number(testConcurrency) === 5) {
320
327
  // outputStr += `\n${concurrencyMsg}\n`
321
328
  // }
322
- let isSuccess;
323
- if (errors.length) {
324
- isSuccess = false;
325
- }
326
- else if (failOnDiff) {
327
- isSuccess = !warnForUnsavedNewTests && passedOrNew.length && !unresolvedOrFailed.length;
328
- }
329
- else {
330
- isSuccess = true;
331
- }
329
+ const isSuccess = { onErrors: true, onDiffs: true };
330
+ isSuccess.onErrors = !errors.length;
331
+ isSuccess.onDiffs = !!(!warnForUnsavedNewTests && passedOrNew.length && !unresolvedOrFailed.length);
332
332
  return {
333
333
  outputStr,
334
334
  isSuccess,
@@ -141,8 +141,8 @@ async function takeDomSnapshots({ driver, settings, hooks, provides, logger, })
141
141
  if (utils.types.isNumber(settings.waitBeforeCapture)) {
142
142
  await utils.general.sleep(settings.waitBeforeCapture);
143
143
  }
144
- else {
145
- await ((_b = settings.waitBeforeCapture) === null || _b === void 0 ? void 0 : _b.call(settings));
144
+ else if (settings.waitBeforeCapture) {
145
+ await ((_b = driver.executeUserFunction) === null || _b === void 0 ? void 0 : _b.call(driver, settings.waitBeforeCapture));
146
146
  }
147
147
  }
148
148
  function calculateBreakpoint({ breakpoints, value }) {
@@ -151,9 +151,33 @@ function makeSpec({ socket, spec, }) {
151
151
  async reload(driver) {
152
152
  return socket.request('Driver.reload', { driver });
153
153
  },
154
+ async isUserFunction(ref) {
155
+ return utils.types.has(ref, 'applitools-ref-id');
156
+ },
157
+ async executeUserFunction(userFunction) {
158
+ return socket.request('Driver.executeUserFunction', userFunction);
159
+ },
154
160
  };
161
+ // add default commands to spec (if not already there) such as `isUserFunction`
162
+ spec = addDefaultCommands(spec);
155
163
  return spec.reduce((spec, name) => {
156
164
  return Object.assign(spec, { [name]: commands[name] });
157
165
  }, {});
158
166
  }
159
167
  exports.makeSpec = makeSpec;
168
+ // returns a new clone of the spec commands array with additional commands universal can support even if the spec doesn't
169
+ function addDefaultCommands(spec) {
170
+ const defaultCommands = [
171
+ {
172
+ command: 'isUserFunction',
173
+ dependsOn: ['executeUserFunction'],
174
+ },
175
+ ];
176
+ const commands = spec.slice();
177
+ defaultCommands.forEach(({ command, dependsOn }) => {
178
+ if (!commands.includes(command) && dependsOn.every(dep => commands.includes(dep))) {
179
+ commands.push(command);
180
+ }
181
+ });
182
+ return commands;
183
+ }
@@ -29,7 +29,8 @@ function populateEyesServerSettings(settings) {
29
29
  var _a, _b, _c, _d, _e, _f;
30
30
  (_a = settings.eyesServerUrl) !== null && _a !== void 0 ? _a : (settings.eyesServerUrl = (_c = (_b = utils.general.getEnvValue('EYES_SERVER_URL')) !== null && _b !== void 0 ? _b : utils.general.getEnvValue('SERVER_URL')) !== null && _c !== void 0 ? _c : 'https://eyesapi.applitools.com');
31
31
  (_d = settings.apiKey) !== null && _d !== void 0 ? _d : (settings.apiKey = utils.general.getEnvValue('API_KEY'));
32
- (_e = settings.proxy) !== null && _e !== void 0 ? _e : (settings.proxy = utils.general.getEnvValue('PROXY_URL') ? { url: utils.general.getEnvValue('PROXY_URL') } : undefined);
32
+ const proxyUrl = utils.general.getEnvValue('PROXY_URL');
33
+ (_e = settings.proxy) !== null && _e !== void 0 ? _e : (settings.proxy = proxyUrl ? { url: proxyUrl } : undefined);
33
34
  (_f = settings.useDnsCache) !== null && _f !== void 0 ? _f : (settings.useDnsCache = utils.general.getEnvValue('USE_DNS_CACHE', 'boolean'));
34
35
  return {
35
36
  eyesServerUrl: settings.eyesServerUrl,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applitools/core",
3
- "version": "4.32.2",
3
+ "version": "4.34.0",
4
4
  "homepage": "https://applitools.com",
5
5
  "bugs": {
6
6
  "url": "https://github.com/applitools/eyes.sdk.javascript1/issues"
@@ -75,20 +75,20 @@
75
75
  }
76
76
  },
77
77
  "dependencies": {
78
- "@applitools/core-base": "1.22.2",
79
- "@applitools/dom-capture": "11.5.4",
80
- "@applitools/dom-snapshot": "4.11.16",
81
- "@applitools/driver": "1.20.5",
82
- "@applitools/ec-client": "1.10.5",
83
- "@applitools/logger": "2.1.1",
84
- "@applitools/nml-client": "1.8.25",
85
- "@applitools/req": "1.7.8",
86
- "@applitools/screenshoter": "3.10.6",
78
+ "@applitools/core-base": "1.22.3",
79
+ "@applitools/dom-capture": "11.5.5",
80
+ "@applitools/dom-snapshot": "4.11.17",
81
+ "@applitools/driver": "1.21.0",
82
+ "@applitools/ec-client": "1.10.7",
83
+ "@applitools/logger": "2.1.2",
84
+ "@applitools/nml-client": "1.8.27",
85
+ "@applitools/req": "1.7.9",
86
+ "@applitools/screenshoter": "3.11.0",
87
87
  "@applitools/snippets": "2.6.4",
88
- "@applitools/socket": "1.2.2",
89
- "@applitools/spec-driver-webdriver": "1.1.26",
90
- "@applitools/ufg-client": "1.16.7",
91
- "@applitools/utils": "1.7.8",
88
+ "@applitools/socket": "1.2.3",
89
+ "@applitools/spec-driver-webdriver": "1.2.1",
90
+ "@applitools/ufg-client": "1.16.8",
91
+ "@applitools/utils": "1.8.0",
92
92
  "@types/ws": "8.5.5",
93
93
  "abort-controller": "3.0.0",
94
94
  "chalk": "4.1.2",
@@ -101,11 +101,11 @@
101
101
  "devDependencies": {
102
102
  "@applitools/bongo": "^5.10.0",
103
103
  "@applitools/sea": "^1.0.0",
104
- "@applitools/spec-driver-puppeteer": "^1.4.25",
105
- "@applitools/spec-driver-selenium": "^1.5.96",
104
+ "@applitools/spec-driver-puppeteer": "^1.4.26",
105
+ "@applitools/spec-driver-selenium": "^1.5.97",
106
106
  "@applitools/test-server": "^1.2.2",
107
107
  "@applitools/test-utils": "^1.5.17",
108
- "@applitools/tunnel-client": "^1.6.3",
108
+ "@applitools/tunnel-client": "^1.6.4",
109
109
  "@types/node": "^12.20.55",
110
110
  "@types/selenium-webdriver": "^4.1.2",
111
111
  "@types/semver": "^7.5.8",
@@ -147,7 +147,7 @@ export interface ScreenshotSettings<TSpec extends SpecType> extends BaseCore.Ima
147
147
  top?: number;
148
148
  bottom?: number;
149
149
  };
150
- waitBeforeCapture?: number;
150
+ waitBeforeCapture?: number | (() => Promise<void>);
151
151
  waitBetweenStitches?: number;
152
152
  lazyLoad?: boolean | LazyLoadOptions;
153
153
  sendDom?: boolean;
@@ -5,6 +5,7 @@ import type { SpecType } from '@applitools/driver';
5
5
  export type OfflineSnapshotsSettings = EyesServerSettings & {
6
6
  offlineLocationPath: string;
7
7
  failOnDiff: boolean;
8
+ failOnError: boolean;
8
9
  config: Config<SpecType, 'ufg'>;
9
10
  logger?: Logger;
10
11
  jsonFilePath?: string;
@@ -4,9 +4,12 @@ export type Driver = Ref;
4
4
  export type Context = Ref;
5
5
  export type Element = Ref;
6
6
  export type Selector = string | CommonSelector | Ref;
7
- export type PrimarySpecType = SpecType<Driver, Context, Element, Selector>;
7
+ export type UserFunction = Ref;
8
+ export type PrimarySpecType = SpecType<Driver, Context, Element, Selector, never, UserFunction>;
8
9
  export type SpecDriver = BaseSpecDriver<PrimarySpecType>;
10
+ type CommandName = keyof UniversalSpecDriver<PrimarySpecType>;
9
11
  export declare function makeSpec({ socket, spec, }: {
10
12
  socket: ServerSocket<PrimarySpecType, any>;
11
- spec: (keyof UniversalSpecDriver<PrimarySpecType>)[];
13
+ spec: CommandName[];
12
14
  }): SpecDriver;
15
+ export {};
@@ -192,5 +192,7 @@ export interface UniversalSpecDriver<T extends SpecType> {
192
192
  reload(options: {
193
193
  driver: T['driver'];
194
194
  }): Promise<void>;
195
+ isUserFunction(ref: any): Promise<boolean>;
196
+ executeUserFunction(userFunction: Ref): Promise<any>;
195
197
  }
196
198
  export {};