@testim/testim-cli 3.198.0 → 3.202.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.
@@ -32,7 +32,7 @@ class OverrideTestDataBuilder {
32
32
  }
33
33
  }
34
34
  if (this.isObjectNotArray(params) && typeof params.overrideAllTestsData !== 'undefined') {
35
- if (this.isObjectNotArray(params.overrideAllTestsData) && !_.isEmpty(params.overrideAllTestsData)) {
35
+ if (_.isObject(params.overrideAllTestsData) && !_.isEmpty(params.overrideAllTestsData)) {
36
36
  const testNames = this.testInfoList.map(test => test.name);
37
37
  testNames.forEach(testName => this.overrideSingeTest(testName, params.overrideAllTestsData));
38
38
  delete params.overrideAllTestsData;
@@ -37,7 +37,6 @@ class FeatureFlagsService {
37
37
  useSafariWebdriverVisibilityChecks: new Rox.Flag(),
38
38
  useClickimVisibilityChecks: new Rox.Flag(),
39
39
  useIEWebdriverVisibilityChecks: new Rox.Flag(),
40
- enableTDKRun: new Rox.Flag(true),
41
40
  runGetElementCodeInAut: new Rox.Flag(),
42
41
  enableNpmPackageInstallUsingNpmCli: new Rox.Flag(),
43
42
  enableFrameSwitchOptimization: new Rox.Flag(),
@@ -47,8 +46,6 @@ class FeatureFlagsService {
47
46
  warnOnBadNetwork: new Rox.Flag(false),
48
47
  overrideAzureStorageUrl: new Rox.Flag(),
49
48
  useJsInputCodeInSafari: new Rox.Flag(),
50
- testNameTestDataInJunitReport: new Rox.Flag(),
51
- countRetries: new Rox.Flag(),
52
49
  autoSaveDownloadFileFireFox: new Rox.Flag(true),
53
50
  safariSelectOptionDispatchEventOnSelectElement: new Rox.Flag(true),
54
51
  experimentalPreCodeCompilation: new Rox.Flag(false),
package/commons/logger.js CHANGED
@@ -1,7 +1,9 @@
1
1
  'use strict';
2
2
 
3
- const bunyan = require('bunyan');
3
+ const winston = require('winston');
4
+ const os = require('os');
4
5
 
6
+ const hostname = os.hostname();
5
7
  const runnerVersion = getRunnerVersion();
6
8
  const config = require('./config');
7
9
 
@@ -24,42 +26,45 @@ function getRunnerVersion() {
24
26
  }
25
27
 
26
28
  function getStreamsAndWaitForFlushPromise() {
27
- const level = config.LOGGER_DEBUG ? 'debug' : 'info';
28
- const streams = [];
29
+ const transports = [];
29
30
 
30
31
  let waitForFlush = () => Promise.resolve();
31
32
 
32
33
  if (!config.IS_ON_PREM) {
33
- const CoralogixBunyan = require('../lib/coralogix-bunyan.stream');
34
+ const { CoralogixTransport } = require('../lib/coralogix-winston.transport');
34
35
 
35
- waitForFlush = CoralogixBunyan.CoralogixStream.waitForFlush;
36
-
37
- CoralogixBunyan.CoralogixStream.configure(loggerConfig);
38
- streams.push({
39
- level,
40
- stream: new CoralogixBunyan.CoralogixStream({ category: 'ROOT' }),
41
- type: 'raw',
36
+ CoralogixTransport.configure(loggerConfig);
37
+ const loggerInstance = new CoralogixTransport({
38
+ category: 'ROOT',
42
39
  });
40
+ transports.push(loggerInstance);
41
+
42
+ waitForFlush = () => loggerInstance.waitForFlush();
43
43
  }
44
44
 
45
45
  if (config.LOGGER_CONSOLE) {
46
- const PrettyStream = require('bunyan-prettystream');
47
- const prettyStdOut = new PrettyStream();
48
- prettyStdOut.pipe(process.stdout);
49
- streams.push({
50
- level,
51
- stream: prettyStdOut,
52
- type: 'raw',
53
- });
46
+ transports.push(new winston.transports.Console({
47
+ format: winston.format.combine(winston.format.colorize(), winston.format.simple()),
48
+ }));
54
49
  }
55
- return [streams, waitForFlush];
50
+ return [transports, waitForFlush];
56
51
  }
57
52
 
58
- const [streams, waitForFlush] = getStreamsAndWaitForFlushPromise();
53
+ const [transports, waitForFlush] = getStreamsAndWaitForFlushPromise();
54
+ const level = config.LOGGER_DEBUG ? 'debug' : 'info';
55
+ const defaultMeta = {};
56
+ if (isLocal.indexOf('@echo') === -1) {
57
+ Object.assign(defaultMeta, devFlags());
59
58
 
60
- const bunyanMainLogger = bunyan.createLogger({
61
- name: 'runner',
62
- streams,
59
+ } else {
60
+ Object.assign(defaultMeta, localFlags());
61
+ }
62
+
63
+ const winstonMainLogger = winston.createLogger({
64
+ levels: winston.config.syslog.levels,
65
+ level,
66
+ transports,
67
+ defaultMeta: { name: 'runner', hostname, nodeVersion: process.version, runnerVersion, ...defaultMeta },
63
68
  });
64
69
 
65
70
  let executionId = null;
@@ -77,8 +82,8 @@ function setProxyUri(proxyUri) {
77
82
  if (config.IS_ON_PREM || !proxyUri) {
78
83
  return;
79
84
  }
80
- const CoralogixBunyan = require('../lib/coralogix-bunyan.stream');
81
- CoralogixBunyan.CoralogixStream.configure({ ...loggerConfig, proxyUri });
85
+ const { CoralogixTransport } = require('../lib/coralogix-winston.transport');
86
+ CoralogixTransport.configure({ ...loggerConfig, proxyUri });
82
87
  }
83
88
 
84
89
  function releaseFlags() {
@@ -102,53 +107,58 @@ function localFlags() {
102
107
  };
103
108
  }
104
109
 
105
- function addExecutionId(logData = {}) {
106
- if (executionId && !logData.executionId) {
110
+ function addExecutionMetadata(dataExecutionId) {
111
+ const logData = {};
112
+ if (executionId && !dataExecutionId) {
107
113
  logData.executionId = executionId;
108
114
  }
109
115
 
110
- logData.runnerVersion = runnerVersion;
111
116
  logData.projectId = projectId;
112
- logData.nodeVersion = process.version;
113
-
114
- if (isLocal.indexOf('@echo') === -1) {
115
- Object.assign(logData, devFlags());
116
-
117
+ logData.time = (new Date()).toISOString();
117
118
 
118
- return logData;
119
- }
120
-
121
- Object.assign(logData, localFlags());
122
119
  return logData;
123
120
  }
124
121
 
125
122
  class Logger {
126
123
  constructor(logger) {
127
124
  this._logger = logger;
128
- }
129
-
130
- trace(msg, data = {}) {
131
- this._logger.trace(addExecutionId(data), msg);
125
+ this.debug = this.debug.bind(this);
126
+ this.info = this.info.bind(this);
127
+ this.warn = this.warn.bind(this);
128
+ this.error = this.error.bind(this);
129
+ this.fatal = this.fatal.bind(this);
132
130
  }
133
131
 
134
132
  debug(msg, data = {}) {
135
- this._logger.debug(addExecutionId(data), msg);
133
+ this.innerLog('debug', msg, data);
136
134
  }
137
135
 
138
136
  info(msg, data = {}) {
139
- this._logger.info(addExecutionId(data), msg);
137
+ this.innerLog('info', msg, data);
140
138
  }
141
139
 
142
140
  warn(msg, data = {}) {
143
- this._logger.warn(addExecutionId(data), msg);
141
+ this.innerLog('warning', msg, data);
144
142
  }
145
143
 
146
144
  error(msg, data = {}) {
147
- this._logger.error(addExecutionId(data), msg);
145
+ this.innerLog('error', msg, data);
148
146
  }
149
147
 
150
148
  fatal(msg, data = {}) {
151
- this._logger.fatal(addExecutionId(data), msg);
149
+ this.innerLog('crit', msg, data);
150
+ }
151
+
152
+ innerLog(level, msg, data = {}) {
153
+ try {
154
+ this._logger.log(level, Object.assign({ meta: data }, { message: msg }, addExecutionMetadata(data.executionId)));
155
+ } catch (err) {
156
+ try {
157
+ this._logger.log('crit', Object.assign({ message: `failed to log message ${err.message}, ${err.stack}` }, addExecutionMetadata(data.executionId)));
158
+ } catch (err) {
159
+ // well what can we do
160
+ }
161
+ }
152
162
  }
153
163
 
154
164
  waitForFlush() {
@@ -157,7 +167,7 @@ class Logger {
157
167
  }
158
168
 
159
169
  function getLogger(loggerName) {
160
- return new Logger(bunyanMainLogger.child({ category: loggerName }));
170
+ return new Logger(winstonMainLogger.child({ category: loggerName }));
161
171
  }
162
172
 
163
173
  module.exports = {
package/executionQueue.js CHANGED
@@ -3,8 +3,8 @@
3
3
  const TestRun = require('./testRunHandler.js');
4
4
 
5
5
  class ExecutionQueue {
6
- constructor(executionId, testList, options, branchToUse, testStatus) {
7
- this._waitingTests = testList.map(testInfo => new TestRun(executionId, testInfo, options, branchToUse, testStatus));
6
+ constructor(executionId, executionName, testList, options, branchToUse, testStatus) {
7
+ this._waitingTests = testList.map(testInfo => new TestRun(executionId, executionName, testInfo, options, branchToUse, testStatus));
8
8
  }
9
9
 
10
10
  getNext() {
@@ -0,0 +1,106 @@
1
+ const { Log, Severity, CoralogixLogger } = require('@testim/coralogix-logger');
2
+ const TransportStream = require('winston-transport');
3
+
4
+ const severityMap = {
5
+ silly: Severity.verbose,
6
+ verbose: Severity.verbose,
7
+ info: Severity.info,
8
+ http: Severity.info,
9
+ warn: Severity.warning,
10
+ warning: Severity.warning,
11
+ error: Severity.error,
12
+ silent: Severity.verbose,
13
+ critical: Severity.critical,
14
+ crit: Severity.critical,
15
+ debug: Severity.debug,
16
+ };
17
+
18
+ class CoralogixTransport extends TransportStream {
19
+ static options;
20
+ constructor(options) {
21
+ options = Object.assign({}, CoralogixTransport.options, options);
22
+ super(options);
23
+ this.options = options;
24
+ this.logger = new CoralogixLogger(options.category);
25
+ this.name = 'Coralogix Transport';
26
+ if (options.timestamp) {
27
+ this.timestamp = options.timestamp;
28
+ }
29
+ }
30
+
31
+ log(info, callback) {
32
+ const { category, level, message: msg, meta: infoMeta = {}, ...restMeta } = info;
33
+ const meta = Object.assign({}, infoMeta, this.options.extraFields, restMeta);
34
+ const log = new Log();
35
+
36
+ log.severity = severityMap[level];
37
+ log.text = msg;
38
+ log.category = category;
39
+ if (meta.className) {
40
+ log.className = meta.className;
41
+ }
42
+ if (meta.methodName) {
43
+ log.methodName = meta.methodName;
44
+ }
45
+ if (meta.threadId) {
46
+ log.threadId = meta.threadId;
47
+ }
48
+ delete meta.className;
49
+ delete meta.methodName;
50
+ delete meta.threadId;
51
+ delete meta.category;
52
+ delete meta.level;
53
+ delete meta.message;
54
+ let errorOverride = false;
55
+ if (infoMeta instanceof Error) {
56
+ errorOverride = true;
57
+ meta.msg = infoMeta.message + infoMeta.stack;
58
+ if (msg) {
59
+ meta.msg = `${msg}\n${meta.msg}`;
60
+ }
61
+ }
62
+ if (infoMeta.err instanceof Error) {
63
+ meta.err = {
64
+ message: infoMeta.err.message,
65
+ stack: infoMeta.err.stack,
66
+ name: infoMeta.err.name,
67
+ type: infoMeta.err.type,
68
+ cause: infoMeta.err.cause,
69
+ ...infoMeta.err,
70
+ };
71
+ }
72
+
73
+ if (infoMeta.reason instanceof Error) {
74
+ meta.reason = {
75
+ message: infoMeta.reason.message,
76
+ stack: infoMeta.reason.stack,
77
+ name: infoMeta.reason.name,
78
+ type: infoMeta.reason.type,
79
+ cause: infoMeta.reason.cause,
80
+ ...infoMeta.reason,
81
+ };
82
+ }
83
+
84
+ // still have keys after deleting the above
85
+ if (Object.keys(meta).length > 0) {
86
+ if (msg && !errorOverride) {
87
+ meta.msg = msg;
88
+ }
89
+ log.text = meta;
90
+ }
91
+
92
+ this.logger.addLog(log);
93
+ callback(null, true);
94
+ }
95
+
96
+ waitForFlush() {
97
+ return this.logger.waitForFlush();
98
+ }
99
+
100
+ static configure(config) {
101
+ CoralogixLogger.configure(config);
102
+ CoralogixTransport.options = config;
103
+ }
104
+ }
105
+
106
+ module.exports.CoralogixTransport = CoralogixTransport;