@testim/testim-cli 3.189.0 → 3.193.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/cli.js CHANGED
@@ -54,7 +54,7 @@ function main() {
54
54
  EventEmitter.defaultMaxListeners = options.parallel * 2;
55
55
  }
56
56
  require('./commons/logger').setProjectId(options.project);
57
- require('./commons/runnerFileCache').setEncryptKey(options.token || 'anonymous_encrypt_key');
57
+ require('./commons/runnerFileCache').setEncryptKey(typeof options.token === 'string' ? options.token : 'anonymous_encrypt_key');
58
58
  })
59
59
  .then(async (options) => {
60
60
  if (options.initCodimMode) {
@@ -74,8 +74,12 @@ function main() {
74
74
  if (!options.playerRequirePath && options.mode !== CLI_MODE.EXTENSION) {
75
75
  await prepareRunnerAndTestimStartUtils.preparePlayer(options.playerLocation, options.canary);
76
76
  }
77
- await runnerFileCache.waitForSave();
78
- console.log(`created prefeched data at ${runnerFileCache.getCacheFileLocation()}`);
77
+ const res = await runnerFileCache.waitForSave();
78
+ if (res.success) {
79
+ console.log(`created prefeched data at ${runnerFileCache.getCacheFileLocation()}`);
80
+ } else {
81
+ console.error('failed to create prefech data', res.error);
82
+ }
79
83
  return undefined;
80
84
  }
81
85
 
@@ -53,6 +53,7 @@ class FeatureFlagsService {
53
53
  safariSelectOptionDispatchEventOnSelectElement: new Rox.Flag(true),
54
54
  experimentalPreCodeCompilation: new Rox.Flag(false),
55
55
  useSameBrowserForMultiTests: new LabFeatureFlag('labs'),
56
+ highSpeedMode: new LabFeatureFlag(),
56
57
  usePortedHtml5DragDrop: new Rox.Flag(),
57
58
  };
58
59
  Rox.register('default', this.flags);
@@ -32,17 +32,43 @@ const getLocalRunnerCache = () => fs.readFileAsync(getCacheFileLocation()).then(
32
32
 
33
33
  let localRunnerCache = getLocalRunnerCache();
34
34
 
35
+ async function doesPathExist(dirPath) {
36
+ try {
37
+ await fs.promises.access(dirPath, fs.constants.F_OK);
38
+ return true;
39
+ } catch (err) {
40
+ if (err.code === 'ENOENT') {
41
+ return false;
42
+ }
43
+
44
+ // no permissions to check
45
+ throw err;
46
+ }
47
+ }
48
+
35
49
  const encryptAndSave = debounce(async (object) => {
36
- const key = await _encryptKeyPromise;
37
- const iv = crypto.randomBytes(16);
38
- const objStr = JSON.stringify(object);
39
- const keyBuffer = Buffer.from(key);
40
- const cipher = crypto.createCipheriv('aes-256-cbc', Buffer.concat([keyBuffer, Buffer.alloc(32)], 32), iv);
41
- const result = Buffer.concat([iv, cipher.update(objStr), cipher.final()]);
42
- await fs.writeFileAsync(getCacheFileLocation(), result).catch((err) => {
50
+ let error;
51
+ try {
52
+ const key = await _encryptKeyPromise;
53
+ const iv = crypto.randomBytes(16);
54
+ const objStr = JSON.stringify(object);
55
+ const keyBuffer = Buffer.from(key);
56
+ const cipher = crypto.createCipheriv('aes-256-cbc', Buffer.concat([keyBuffer, Buffer.alloc(32)], 32), iv);
57
+ const result = Buffer.concat([iv, cipher.update(objStr), cipher.final()]);
58
+ const pathExists = await doesPathExist(cacheLocation);
59
+ if (!pathExists) {
60
+ await fs.promises.mkdir(cacheLocation, { recursive: true });
61
+ }
62
+ await fs.writeFileAsync(getCacheFileLocation(), result);
63
+ } catch (err) {
43
64
  logger.error('failed saving cache', { err });
44
- });
45
- encryptAndSaveResolve();
65
+ error = err;
66
+ }
67
+ if (error) {
68
+ encryptAndSaveResolve({ success: false, error });
69
+ } else {
70
+ encryptAndSaveResolve({ success: true });
71
+ }
46
72
  }, 200);
47
73
 
48
74
  function decrypt(key, buffer) {
@@ -162,6 +162,7 @@ function setTestimExtension(browserOptions, extensions, args, predefinedTestimEx
162
162
  function _buildChromiumOptions(opts, browserOptions, testRunConfig, customExtensionLocalLocation, gridInfo, predefinedTestimExtension, lambdatestService) {
163
163
  // * Make sure to add any referenced attributes of the function arguments to the hash created in buildChromiumOptions * //
164
164
 
165
+ const browserName = testRunConfig.seleniumName || testRunConfig.browserValue;
165
166
  const extensions = [];
166
167
  const args = [...DEFAULT_CHROME_OPTIONS_ARGS];
167
168
  if (browserOptions.headless) {
@@ -191,6 +192,11 @@ function _buildChromiumOptions(opts, browserOptions, testRunConfig, customExtens
191
192
  opts.desiredCapabilities['aws:idleTimeoutSecs'] = 60; // Maximum delay between WebDriver commands before the session is forcibly closed. Range: 30 to 900.
192
193
  }
193
194
 
195
+ if (isDFGrid(gridInfo) && browserName === 'MicrosoftEdge') {
196
+ delete chromiumOptions.prefs['profile.content_settings.exceptions.clipboard']; // for some reason this breaks
197
+ opts.desiredCapabilities['ms:edgeChromium'] = true;
198
+ }
199
+
194
200
  if (browserOptions.chromeExtraPrefs) {
195
201
  Object.assign(chromiumOptions.prefs, browserOptions.chromeExtraPrefs);
196
202
  }
@@ -211,7 +217,6 @@ function _buildChromiumOptions(opts, browserOptions, testRunConfig, customExtens
211
217
  args.push('--disable-gpu');
212
218
  }
213
219
 
214
- const browserName = testRunConfig.seleniumName || testRunConfig.browserValue;
215
220
  Object.assign(opts.desiredCapabilities, { browserName });
216
221
 
217
222
  function setMobileEmulationSettings() {