@applitools/core 4.24.1 → 4.25.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,51 @@
1
1
  # Changelog
2
2
 
3
+ ## [4.25.0](https://github.com/Applitools-Dev/sdk/compare/js/core@4.24.2...js/core@4.25.0) (2024-11-29)
4
+
5
+
6
+ ### Features
7
+
8
+ * offline cli with config ([#2646](https://github.com/Applitools-Dev/sdk/issues/2646)) ([0589dc4](https://github.com/Applitools-Dev/sdk/commit/0589dc429a0c94451e957932106f258dadfd88cc))
9
+
10
+ ## [4.24.2](https://github.com/Applitools-Dev/sdk/compare/js/core@4.24.1...js/core@4.24.2) (2024-11-27)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * don't populate branchName and parentBranchName when scm integration exists ([#2634](https://github.com/Applitools-Dev/sdk/issues/2634)) ([e45d671](https://github.com/Applitools-Dev/sdk/commit/e45d671e11ed40a82de1bd5ab22e757aff00b63f))
16
+ * enhance error logging in takeScreenshots and pollify functions ([#2644](https://github.com/Applitools-Dev/sdk/issues/2644)) ([2428fa5](https://github.com/Applitools-Dev/sdk/commit/2428fa500a9fd47a803aa5aca9f79e5c5b3584f9))
17
+
18
+
19
+ ### Dependencies
20
+
21
+ * @applitools/dom-shared bumped to 1.0.16
22
+ #### Bug Fixes
23
+
24
+ * enhance error logging in takeScreenshots and pollify functions ([#2644](https://github.com/Applitools-Dev/sdk/issues/2644)) ([2428fa5](https://github.com/Applitools-Dev/sdk/commit/2428fa500a9fd47a803aa5aca9f79e5c5b3584f9))
25
+ * @applitools/dom-snapshot bumped to 4.11.11
26
+
27
+ * @applitools/req bumped to 1.7.4
28
+ #### Bug Fixes
29
+
30
+ * set heartbeat request timeout as the request interval ([#2587](https://github.com/Applitools-Dev/sdk/issues/2587)) ([0251d27](https://github.com/Applitools-Dev/sdk/commit/0251d27d9ed44ec247732f66904ae3d4fa4123f1))
31
+ * @applitools/dom-capture bumped to 11.5.2
32
+
33
+ * @applitools/nml-client bumped to 1.8.19
34
+
35
+ * @applitools/tunnel-client bumped to 1.5.10
36
+
37
+ * @applitools/ufg-client bumped to 1.14.1
38
+
39
+ * @applitools/core-base bumped to 1.19.3
40
+ #### Bug Fixes
41
+
42
+ * set heartbeat request timeout as the request interval ([#2587](https://github.com/Applitools-Dev/sdk/issues/2587)) ([0251d27](https://github.com/Applitools-Dev/sdk/commit/0251d27d9ed44ec247732f66904ae3d4fa4123f1))
43
+
44
+
45
+
46
+ * @applitools/ec-client bumped to 1.9.15
47
+
48
+
3
49
  ## [4.24.1](https://github.com/Applitools-Dev/sdk/compare/js/core@4.24.0...js/core@4.24.1) (2024-11-14)
4
50
 
5
51
 
@@ -44,7 +44,10 @@ async function takeScreenshots({ driver, settings, logger, }) {
44
44
  await ((_a = screenshot.scrollingElement) === null || _a === void 0 ? void 0 : _a.setAttribute('data-applitools-scroll', 'true'));
45
45
  else
46
46
  await ((_b = screenshot.element) === null || _b === void 0 ? void 0 : _b.setAttribute('data-applitools-scroll', 'true'));
47
- baseTarget.dom = await (0, take_dom_capture_1.takeDomCapture)({ driver, settings: settings.domSettings, logger }).catch(() => undefined);
47
+ baseTarget.dom = await (0, take_dom_capture_1.takeDomCapture)({ driver, settings: settings.domSettings, logger }).catch(error => {
48
+ logger.error('failed to capture DOM', error);
49
+ return undefined;
50
+ });
48
51
  }
49
52
  if (settings.calculateView) {
50
53
  const scrollingElement = await driver.mainContext.getScrollingElement();
package/dist/cli/cli.js CHANGED
@@ -32,7 +32,6 @@ const core_server_1 = require("../universal/core-server");
32
32
  const core_server_process_1 = require("../universal/core-server-process");
33
33
  const logs_1 = require("../troubleshoot/logs");
34
34
  const check_network_1 = require("../troubleshoot/check-network");
35
- const run_offline_snapshots_1 = require("../run-offline-snapshots");
36
35
  const yargs_1 = __importDefault(require("yargs"));
37
36
  const utils = __importStar(require("@applitools/utils"));
38
37
  const fs_1 = __importDefault(require("fs"));
@@ -152,29 +151,5 @@ void yargs_1.default
152
151
  handler: async () => {
153
152
  await (0, check_network_1.checkNetwork)();
154
153
  },
155
- })
156
- .command({
157
- command: 'run-offline-snapshots',
158
- builder: yargs => yargs
159
- .options({
160
- offlineLocationPath: {
161
- description: 'path to offline snapshots folder',
162
- type: 'string',
163
- },
164
- failOnDiff: {
165
- description: 'should exit process with non-zero exit code, thereby failing the CI job',
166
- type: 'boolean',
167
- default: false,
168
- },
169
- })
170
- .fail((_msg, err, _yargs) => {
171
- if (err) {
172
- console.error(err.message);
173
- process.exit(1);
174
- }
175
- }),
176
- handler: async (args) => {
177
- await (0, run_offline_snapshots_1.runOfflineSnapshots)(args);
178
- },
179
154
  })
180
155
  .wrap(yargs_1.default.terminalWidth()).argv;
package/dist/index.js CHANGED
@@ -35,3 +35,4 @@ __exportStar(require("./autonomous/core"), exports);
35
35
  __exportStar(require("@applitools/driver/dist/debug"), exports);
36
36
  exports.formatters = __importStar(require("./utils/format-results"));
37
37
  exports.logs = __importStar(require("./troubleshoot/logs"));
38
+ __exportStar(require("./offline/run-offline-snapshots"), exports);
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.mergeConfigs = void 0;
27
+ const utils = __importStar(require("@applitools/utils"));
28
+ function mergeConfigs(base, other) {
29
+ return Object.entries(other).reduce((base, [key, value]) => {
30
+ if (utils.types.has(base, key) &&
31
+ utils.types.isObject(value) &&
32
+ !(value instanceof String) &&
33
+ !utils.types.isArray(value)) {
34
+ base[key] = mergeConfigs(base[key], value);
35
+ }
36
+ else if (value !== undefined) {
37
+ base[key] = value;
38
+ }
39
+ return base;
40
+ }, { ...base });
41
+ }
42
+ exports.mergeConfigs = mergeConfigs;
@@ -29,19 +29,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.runOfflineSnapshots = void 0;
30
30
  const fs_1 = __importDefault(require("fs"));
31
31
  const path_1 = __importDefault(require("path"));
32
- const core_1 = require("./core");
33
- const get_ufg_client_1 = require("./ufg/get-ufg-client");
32
+ const core_1 = require("../core");
33
+ const get_ufg_client_1 = require("../ufg/get-ufg-client");
34
34
  const logger_1 = require("@applitools/logger");
35
- const to_base_check_settings_1 = require("./automation/utils/to-base-check-settings");
35
+ const to_base_check_settings_1 = require("../automation/utils/to-base-check-settings");
36
36
  const chalk_1 = __importDefault(require("chalk"));
37
37
  const utils = __importStar(require("@applitools/utils"));
38
+ const merge_configs_1 = require("./merge-configs");
38
39
  async function runOfflineSnapshots(options) {
40
+ var _a, _b;
39
41
  if (!options.offlineLocationPath)
40
42
  throw new Error('offlineLocationPath is required');
41
43
  const startTime = Date.now();
42
- const logger = (0, logger_1.makeLogger)({ format: { label: 'offline-exec' } });
44
+ const logger = (_a = options.logger) !== null && _a !== void 0 ? _a : (0, logger_1.makeLogger)({ format: { label: 'offline-exec' } });
45
+ const eyesServerSettings = { ...(_b = options.config) === null || _b === void 0 ? void 0 : _b.open, ...options };
43
46
  const core = (0, core_1.makeCore)();
44
- const account = await core.getAccountInfo({ settings: options });
47
+ const account = await core.getAccountInfo({ settings: eyesServerSettings });
45
48
  const ufgClient = await (0, get_ufg_client_1.makeGetUFGClient)({ logger })({
46
49
  settings: { ...account.eyesServer, ...account.ufgServer },
47
50
  });
@@ -66,6 +69,7 @@ async function runOfflineSnapshots(options) {
66
69
  else {
67
70
  logger.console.log(outputStr);
68
71
  }
72
+ return allTestResults;
69
73
  async function runExecution(executionName) {
70
74
  const executionLogger = logger.extend({ tags: [executionName] });
71
75
  const executionPath = path_1.default.resolve(options.offlineLocationPath, executionName);
@@ -75,9 +79,10 @@ async function runOfflineSnapshots(options) {
75
79
  const results = await Promise.all(testFolders.map(async (testFolder) => {
76
80
  const testLogger = logger.extend({ tags: [testFolder] });
77
81
  const testPath = path_1.default.resolve(executionPath, testFolder);
78
- const openSettings = (await fs_1.default.promises
82
+ const fileOpenSettings = await fs_1.default.promises
79
83
  .readFile(path_1.default.resolve(testPath, 'settings.json'), 'utf-8')
80
- .then(JSON.parse));
84
+ .then(JSON.parse);
85
+ const openSettings = (0, merge_configs_1.mergeConfigs)(fileOpenSettings, options.config.open);
81
86
  logger.console.log(`Running test: ${openSettings.testName} (${formatEnvironment(openSettings.environment)})`);
82
87
  return runTest(executionPath, testPath, openSettings, testLogger);
83
88
  }));
@@ -110,9 +115,9 @@ async function runOfflineSnapshots(options) {
110
115
  // logger.log('resource hashes for test', testFolder, ':', resourceHashes)
111
116
  logger.log('uploaded resources for test', testPath);
112
117
  await Promise.all(targets.map((target, index) => runCheck(eyes, target, index, logger)));
113
- await eyes.close({
114
- settings: await fs_1.default.promises.readFile(path_1.default.resolve(testPath, 'close.json'), 'utf-8').then(JSON.parse),
115
- });
118
+ const fileCloseSettings = await fs_1.default.promises.readFile(path_1.default.resolve(testPath, 'close.json'), 'utf-8').then(JSON.parse);
119
+ const closeSettings = (0, merge_configs_1.mergeConfigs)(fileCloseSettings, options.config.close);
120
+ await eyes.close({ settings: closeSettings });
116
121
  logger.log('done running test', logger);
117
122
  return { batchId: openSettings.batch.id, results: (await eyes.getResults({ logger }))[0] };
118
123
  }
@@ -180,9 +185,10 @@ async function runOfflineSnapshots(options) {
180
185
  baseSettings.stepIndex = index;
181
186
  baseTarget.source = target.target.source; // TODO verify
182
187
  // baseTarget.name = snapshot.title // TODO figure out
188
+ const mergedCheckSettings = (0, merge_configs_1.mergeConfigs)(baseSettings, options.config.check);
183
189
  await eyes.check({
184
190
  target: { ...baseTarget, isTransformed: true },
185
- settings: baseSettings,
191
+ settings: mergedCheckSettings,
186
192
  logger: checkLogger,
187
193
  });
188
194
  }
package/dist/open-eyes.js CHANGED
@@ -142,8 +142,8 @@ function makeOpenEyes({ type: defaultType = 'classic', clients, batch, removeDup
142
142
  }); // TODO solve the types issue
143
143
  /////// END FUNCTION BODY ///////////////////
144
144
  async function populateAutoScmInfo(batchId) {
145
- var _a, _b, _c, _d;
146
- var _e;
145
+ var _a, _b;
146
+ var _c;
147
147
  const branchName = await (0, extract_git_info_1.extractGitBranch)({ execOptions: { cwd }, logger });
148
148
  const { owner: repoOwner, name: repoName } = await (0, extract_git_info_1.extractGitRepo)({ execOptions: { cwd }, logger });
149
149
  const buildId = await (0, extract_git_info_1.extractBuildIdFromCI)();
@@ -159,9 +159,8 @@ function makeOpenEyes({ type: defaultType = 'classic', clients, batch, removeDup
159
159
  if (scmInfo) {
160
160
  (_a = settings.batch) !== null && _a !== void 0 ? _a : (settings.batch = {});
161
161
  settings.batch.id = isRealBatchId(settings.batch.id) ? settings.batch.id : batchId;
162
- (_b = (_e = settings.batch).buildId) !== null && _b !== void 0 ? _b : (_e.buildId = buildId);
163
- (_c = settings.branchName) !== null && _c !== void 0 ? _c : (settings.branchName = branchName);
164
- (_d = settings.parentBranchName) !== null && _d !== void 0 ? _d : (settings.parentBranchName = scmInfo.scmTargetBranch);
162
+ (_b = (_c = settings.batch).buildId) !== null && _b !== void 0 ? _b : (_c.buildId = buildId);
163
+ // Intentionally not auto populating branchName and parentBranchName. If there is scmInfo then Eyes already knows these values.
165
164
  }
166
165
  }
167
166
  else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applitools/core",
3
- "version": "4.24.1",
3
+ "version": "4.25.0",
4
4
  "homepage": "https://applitools.com",
5
5
  "bugs": {
6
6
  "url": "https://github.com/applitools/eyes.sdk.javascript1/issues"
@@ -28,8 +28,8 @@
28
28
  "./package.json": "./package.json"
29
29
  },
30
30
  "bin": {
31
- "eyes": "./dist/cli/cli.js",
32
- "eyes-check-network": "./dist/troubleshoot/check-network.js"
31
+ "eyes-check-network": "./dist/troubleshoot/check-network.js",
32
+ "eyes-core": "./dist/cli/cli.js"
33
33
  },
34
34
  "main": "./dist/index.js",
35
35
  "types": "./types/index.d.ts",
@@ -49,8 +49,8 @@
49
49
  "build:bin:zip": "zip -j ./bin/core.zip $(find ./bin -type f -not -name '*.zip' -not -name '*.tar.gz' | xargs)",
50
50
  "build:bin:tgz": "tar -czf ./bin/core.tar.gz $(find ./bin -type f -not -name '*.zip' -not -name '*.tar.gz' | xargs)",
51
51
  "test": "run --top-level mocha './test/**/*.spec.ts' --exclude './test/bin/**' --parallel --jobs ${MOCHA_JOBS:-15} --exit",
52
- "test:local": "MOCHA_OMIT_TAGS=sauce run test",
53
- "test:sauce": "MOCHA_ONLY_TAGS=sauce run test",
52
+ "test:local": "MOCHA_OMIT_TAGS=sauce,browserstack run test",
53
+ "test:sauce": "MOCHA_ONLY_TAGS=sauce,browserstack run test",
54
54
  "test:bin": "MOCHA_GROUP=bin run --top-level mocha './test/bin/**/*.spec.ts' --parallel --jobs ${MOCHA_JOBS:-15}",
55
55
  "test:e2e": "MOCHA_GROUP=e2e run --top-level mocha './test/e2e/**/*.spec.ts' --parallel --jobs ${MOCHA_JOBS:-15} --exit",
56
56
  "test:it": "MOCHA_GROUP=it run --top-level mocha './test/it/**/*.spec.ts'",
@@ -58,7 +58,7 @@
58
58
  "setup": "run --top-level browsers:setup"
59
59
  },
60
60
  "sea": {
61
- "bin": "eyes",
61
+ "bin": "eyes-core",
62
62
  "certs": {
63
63
  "win": {
64
64
  "cert": "env.CODE_SIGNING_CERT_WIN",
@@ -74,19 +74,19 @@
74
74
  }
75
75
  },
76
76
  "dependencies": {
77
- "@applitools/core-base": "1.19.2",
78
- "@applitools/dom-capture": "11.5.1",
79
- "@applitools/dom-snapshot": "4.11.10",
77
+ "@applitools/core-base": "1.19.3",
78
+ "@applitools/dom-capture": "11.5.2",
79
+ "@applitools/dom-snapshot": "4.11.11",
80
80
  "@applitools/driver": "1.20.0",
81
- "@applitools/ec-client": "1.9.14",
81
+ "@applitools/ec-client": "1.9.15",
82
82
  "@applitools/logger": "2.0.19",
83
- "@applitools/nml-client": "1.8.18",
84
- "@applitools/req": "1.7.3",
83
+ "@applitools/nml-client": "1.8.19",
84
+ "@applitools/req": "1.7.4",
85
85
  "@applitools/screenshoter": "3.10.0",
86
86
  "@applitools/snippets": "2.6.3",
87
87
  "@applitools/socket": "1.1.19",
88
88
  "@applitools/spec-driver-webdriver": "1.1.20",
89
- "@applitools/ufg-client": "1.14.0",
89
+ "@applitools/ufg-client": "1.14.1",
90
90
  "@applitools/utils": "1.7.5",
91
91
  "@types/ws": "8.5.5",
92
92
  "abort-controller": "3.0.0",
@@ -104,7 +104,7 @@
104
104
  "@applitools/spec-driver-selenium": "^1.5.91",
105
105
  "@applitools/test-server": "^1.2.2",
106
106
  "@applitools/test-utils": "^1.5.17",
107
- "@applitools/tunnel-client": "^1.5.9",
107
+ "@applitools/tunnel-client": "^1.5.10",
108
108
  "@types/node": "^12.20.55",
109
109
  "@types/selenium-webdriver": "^4.1.2",
110
110
  "@types/semver": "^7.5.8",
package/types/index.d.ts CHANGED
@@ -7,3 +7,4 @@ export { type SpecType, type SpecDriver, type Selector } from '@applitools/drive
7
7
  export * from '@applitools/driver/dist/debug';
8
8
  export * as formatters from './utils/format-results';
9
9
  export * as logs from './troubleshoot/logs';
10
+ export * from './offline/run-offline-snapshots';
@@ -0,0 +1 @@
1
+ export declare function mergeConfigs<TBase extends Record<string, any>>(base: TBase, other: Record<string, any>): TBase;
@@ -0,0 +1,11 @@
1
+ import { Config, type EyesServerSettings } from '../types';
2
+ import { type Logger } from '@applitools/logger';
3
+ import type { TestResult } from '@applitools/core-base';
4
+ import type { SpecType } from '@applitools/driver';
5
+ export type OfflineSnapshotsSettings = EyesServerSettings & {
6
+ offlineLocationPath: string;
7
+ failOnDiff: boolean;
8
+ config: Config<SpecType, 'ufg'>;
9
+ logger?: Logger;
10
+ };
11
+ export declare function runOfflineSnapshots(options: OfflineSnapshotsSettings): Promise<TestResult[]>;
@@ -1,6 +0,0 @@
1
- import { type EyesServerSettings } from './types';
2
- export type OfflineSnapshotsSettings = EyesServerSettings & {
3
- offlineLocationPath: string;
4
- failOnDiff: boolean;
5
- };
6
- export declare function runOfflineSnapshots(options: OfflineSnapshotsSettings): Promise<void>;