@testomatio/reporter 2.0.1-beta.4 → 2.0.1-beta.5-timestamp

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.
Files changed (148) hide show
  1. package/lib/adapter/codecept.js +335 -293
  2. package/lib/adapter/cucumber/current.js +203 -195
  3. package/lib/adapter/cucumber/legacy.js +155 -130
  4. package/lib/adapter/cucumber.js +16 -5
  5. package/lib/adapter/cypress-plugin/index.js +105 -91
  6. package/lib/adapter/jasmine.js +53 -54
  7. package/lib/adapter/jest.js +99 -97
  8. package/lib/adapter/mocha.js +141 -112
  9. package/lib/adapter/playwright.js +231 -199
  10. package/lib/adapter/vitest.js +149 -150
  11. package/lib/adapter/webdriver.js +121 -144
  12. package/lib/bin/cli.js +211 -229
  13. package/lib/bin/reportXml.js +52 -51
  14. package/lib/bin/startTest.js +95 -83
  15. package/lib/bin/uploadArtifacts.js +61 -56
  16. package/lib/client.js +465 -424
  17. package/lib/config.js +23 -18
  18. package/lib/constants.js +44 -50
  19. package/lib/data-storage.js +188 -216
  20. package/lib/junit-adapter/adapter.js +20 -17
  21. package/lib/junit-adapter/csharp.js +14 -28
  22. package/lib/junit-adapter/index.js +25 -27
  23. package/lib/junit-adapter/java.js +53 -41
  24. package/lib/junit-adapter/javascript.js +27 -30
  25. package/lib/junit-adapter/python.js +37 -38
  26. package/lib/junit-adapter/ruby.js +8 -11
  27. package/lib/output.js +52 -44
  28. package/lib/pipe/bitbucket.js +230 -223
  29. package/lib/pipe/csv.js +126 -113
  30. package/lib/pipe/debug.js +99 -118
  31. package/lib/pipe/github.js +213 -218
  32. package/lib/pipe/gitlab.js +206 -183
  33. package/lib/pipe/html.js +321 -258
  34. package/lib/pipe/index.js +66 -94
  35. package/lib/pipe/testomatio.js +474 -429
  36. package/lib/reporter-functions.js +26 -28
  37. package/lib/reporter.js +29 -34
  38. package/lib/services/artifacts.js +51 -55
  39. package/lib/services/index.js +12 -14
  40. package/lib/services/key-values.js +53 -56
  41. package/lib/services/logger.js +245 -226
  42. package/lib/template/testomatio.hbs +1366 -1026
  43. package/lib/uploader.js +364 -295
  44. package/lib/utils/pipe_utils.js +85 -89
  45. package/lib/utils/utils.js +307 -398
  46. package/lib/xmlReader.js +532 -525
  47. package/package.json +21 -64
  48. package/lib/adapter/codecept.d.ts +0 -2
  49. package/lib/adapter/cucumber/current.d.ts +0 -14
  50. package/lib/adapter/cucumber/legacy.d.ts +0 -0
  51. package/lib/adapter/cucumber.d.ts +0 -2
  52. package/lib/adapter/cypress-plugin/index.d.ts +0 -2
  53. package/lib/adapter/jasmine.d.ts +0 -11
  54. package/lib/adapter/jest.d.ts +0 -13
  55. package/lib/adapter/mocha.d.ts +0 -2
  56. package/lib/adapter/nightwatch.d.ts +0 -4
  57. package/lib/adapter/nightwatch.js +0 -80
  58. package/lib/adapter/playwright.d.ts +0 -14
  59. package/lib/adapter/vitest.d.ts +0 -35
  60. package/lib/adapter/webdriver.d.ts +0 -24
  61. package/lib/bin/cli.d.ts +0 -2
  62. package/lib/bin/reportXml.d.ts +0 -2
  63. package/lib/bin/startTest.d.ts +0 -2
  64. package/lib/bin/uploadArtifacts.d.ts +0 -2
  65. package/lib/client.d.ts +0 -76
  66. package/lib/config.d.ts +0 -1
  67. package/lib/constants.d.ts +0 -25
  68. package/lib/data-storage.d.ts +0 -34
  69. package/lib/junit-adapter/adapter.d.ts +0 -9
  70. package/lib/junit-adapter/csharp.d.ts +0 -5
  71. package/lib/junit-adapter/index.d.ts +0 -3
  72. package/lib/junit-adapter/java.d.ts +0 -5
  73. package/lib/junit-adapter/javascript.d.ts +0 -4
  74. package/lib/junit-adapter/python.d.ts +0 -5
  75. package/lib/junit-adapter/ruby.d.ts +0 -4
  76. package/lib/output.d.ts +0 -11
  77. package/lib/package.json +0 -3
  78. package/lib/pipe/bitbucket.d.ts +0 -25
  79. package/lib/pipe/csv.d.ts +0 -47
  80. package/lib/pipe/debug.d.ts +0 -29
  81. package/lib/pipe/github.d.ts +0 -30
  82. package/lib/pipe/gitlab.d.ts +0 -25
  83. package/lib/pipe/html.d.ts +0 -35
  84. package/lib/pipe/index.d.ts +0 -1
  85. package/lib/pipe/testomatio.d.ts +0 -71
  86. package/lib/replay.d.ts +0 -31
  87. package/lib/replay.js +0 -237
  88. package/lib/reporter-functions.d.ts +0 -34
  89. package/lib/reporter.d.ts +0 -232
  90. package/lib/services/artifacts.d.ts +0 -33
  91. package/lib/services/index.d.ts +0 -9
  92. package/lib/services/key-values.d.ts +0 -27
  93. package/lib/services/logger.d.ts +0 -64
  94. package/lib/uploader.d.ts +0 -60
  95. package/lib/utils/pipe_utils.d.ts +0 -41
  96. package/lib/utils/utils.d.ts +0 -54
  97. package/lib/xmlReader.d.ts +0 -92
  98. package/src/adapter/codecept.js +0 -373
  99. package/src/adapter/cucumber/current.js +0 -228
  100. package/src/adapter/cucumber/legacy.js +0 -158
  101. package/src/adapter/cucumber.js +0 -4
  102. package/src/adapter/cypress-plugin/index.js +0 -110
  103. package/src/adapter/jasmine.js +0 -60
  104. package/src/adapter/jest.js +0 -107
  105. package/src/adapter/mocha.cjs +0 -2
  106. package/src/adapter/mocha.js +0 -156
  107. package/src/adapter/nightwatch.js +0 -88
  108. package/src/adapter/playwright.js +0 -254
  109. package/src/adapter/vitest.js +0 -183
  110. package/src/adapter/webdriver.js +0 -142
  111. package/src/bin/cli.js +0 -348
  112. package/src/bin/reportXml.js +0 -77
  113. package/src/bin/startTest.js +0 -124
  114. package/src/bin/uploadArtifacts.js +0 -91
  115. package/src/client.js +0 -508
  116. package/src/config.js +0 -30
  117. package/src/constants.js +0 -53
  118. package/src/data-storage.js +0 -204
  119. package/src/junit-adapter/adapter.js +0 -23
  120. package/src/junit-adapter/csharp.js +0 -28
  121. package/src/junit-adapter/index.js +0 -28
  122. package/src/junit-adapter/java.js +0 -58
  123. package/src/junit-adapter/javascript.js +0 -31
  124. package/src/junit-adapter/python.js +0 -42
  125. package/src/junit-adapter/ruby.js +0 -10
  126. package/src/output.js +0 -57
  127. package/src/pipe/bitbucket.js +0 -252
  128. package/src/pipe/csv.js +0 -140
  129. package/src/pipe/debug.js +0 -119
  130. package/src/pipe/github.js +0 -232
  131. package/src/pipe/gitlab.js +0 -247
  132. package/src/pipe/html.js +0 -373
  133. package/src/pipe/index.js +0 -71
  134. package/src/pipe/testomatio.js +0 -504
  135. package/src/replay.js +0 -245
  136. package/src/reporter-functions.js +0 -55
  137. package/src/reporter.cjs_decprecated +0 -21
  138. package/src/reporter.js +0 -33
  139. package/src/services/artifacts.js +0 -59
  140. package/src/services/index.js +0 -13
  141. package/src/services/key-values.js +0 -59
  142. package/src/services/logger.js +0 -315
  143. package/src/template/emptyData.svg +0 -23
  144. package/src/template/testomatio.hbs +0 -1081
  145. package/src/uploader.js +0 -376
  146. package/src/utils/pipe_utils.js +0 -119
  147. package/src/utils/utils.js +0 -416
  148. package/src/xmlReader.js +0 -614
@@ -1,106 +1,118 @@
1
1
  #!/usr/bin/env node
2
- "use strict";
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
5
- };
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- const cross_spawn_1 = require("cross-spawn");
8
- const commander_1 = require("commander");
9
- const picocolors_1 = __importDefault(require("picocolors"));
10
- const client_js_1 = __importDefault(require("../client.js"));
11
- const constants_js_1 = require("../constants.js");
12
- const utils_js_1 = require("../utils/utils.js");
13
- const config_js_1 = require("../config.js");
14
- const dotenv_1 = __importDefault(require("dotenv"));
15
- const version = (0, utils_js_1.getPackageVersion)();
16
- console.log(picocolors_1.default.cyan(picocolors_1.default.bold(` 🤩 Testomat.io Reporter v${version}`)));
17
- const program = new commander_1.Command();
2
+ const spawn = require('cross-spawn');
3
+ const { program } = require('commander');
4
+ const chalk = require('chalk');
5
+ const TestomatClient = require('../client');
6
+ const { APP_PREFIX, STATUS } = require('../constants');
7
+ const { version } = require('../../package.json');
8
+ const config = require('../config');
9
+
10
+ console.log(chalk.cyan.bold(` 🤩 Testomat.io Reporter v${version}`));
11
+
18
12
  program
19
- .option('-c, --command <cmd>', 'Test runner command')
20
- .option('--launch', 'Start a new run and return its ID')
21
- .option('--finish', 'Finish Run by its ID')
22
- .option('--env-file <envfile>', 'Load environment variables from env file')
23
- .option('--filter <filter>', 'Additional execution filter')
24
- .action(async (opts) => {
13
+ .option('-c, --command <cmd>', 'Test runner command')
14
+ .option('--launch', 'Start a new run and return its ID')
15
+ .option('--finish', 'Finish Run by its ID')
16
+ .option('--env-file <envfile>', 'Load environment variables from env file')
17
+ .option('--filter <filter>', 'Additional execution filter')
18
+ .action(async opts => {
25
19
  const { launch, finish, filter } = opts;
26
20
  let { command } = opts;
27
- if (opts.envFile)
28
- dotenv_1.default.config({ path: opts.envFile });
29
- const apiKey = process.env['INPUT_TESTOMATIO-KEY'] || config_js_1.config.TESTOMATIO;
21
+
22
+ if (opts.envFile) require('dotenv').config(opts.envFile); // eslint-disable-line
23
+
24
+ const apiKey = process.env['INPUT_TESTOMATIO-KEY'] || config.TESTOMATIO;
30
25
  const title = process.env.TESTOMATIO_TITLE;
26
+
31
27
  if (launch) {
32
- console.log('Starting a new Run on Testomat.io...');
33
- const client = new client_js_1.default({ apiKey });
34
- client.createRun().then(() => {
35
- console.log(process.env.runId);
36
- process.exit(0);
37
- });
38
- return;
28
+ console.log('Starting a new Run on Testomat.io...');
29
+ const client = new TestomatClient({ apiKey });
30
+
31
+ client.createRun().then(() => {
32
+ console.log(process.env.runId);
33
+ process.exit(0);
34
+ });
35
+ return;
39
36
  }
37
+
40
38
  if (finish) {
41
- // TODO: add error in case of TESTOMATIO environment variable is not set
42
- // because command is fine in console, but actually (on testomat.io) run is not finished
43
- if (!process.env.TESTOMATIO_RUN) {
44
- console.log('TESTOMATIO_RUN environment variable must be set.');
45
- return process.exit(1);
46
- }
47
- console.log('Finishing Run on Testomat.io...');
48
- const client = new client_js_1.default({ apiKey });
49
- // @ts-ignore
50
- client.updateRunStatus(constants_js_1.STATUS.FINISHED).then(() => {
51
- console.log(picocolors_1.default.yellow(`Run ${process.env.TESTOMATIO_RUN} was finished`));
52
- process.exit(0);
53
- });
54
- return;
39
+ if (!process.env.TESTOMATIO_RUN) {
40
+ console.log('TESTOMATIO_RUN environment variable must be set.');
41
+ return process.exit(1);
42
+ }
43
+
44
+ console.log('Finishing Run on Testomat.io...');
45
+
46
+ const client = new TestomatClient({ apiKey });
47
+
48
+ client.updateRunStatus(STATUS.FINISHED).then(() => {
49
+ console.log(chalk.yellow(`Run ${process.env.TESTOMATIO_RUN} was finished`));
50
+ process.exit(0);
51
+ });
52
+ return;
55
53
  }
54
+
56
55
  let exitCode = 0;
56
+
57
57
  if (!command.split) {
58
- process.exitCode = 255;
59
- console.log(constants_js_1.APP_PREFIX, `No command provided. Use -c option to launch a test runner.`);
60
- return;
58
+ process.exitCode = 255;
59
+ console.log(APP_PREFIX, `No command provided. Use -c option to launch a test runner.`);
60
+ return;
61
61
  }
62
- const client = new client_js_1.default({ apiKey, title, parallel: true });
62
+
63
+ const client = new TestomatClient({ apiKey, title, parallel: true });
64
+
63
65
  if (filter) {
64
- const [pipe, ...optsArray] = filter.split(':');
65
- const pipeOptions = optsArray.join(':');
66
- try {
67
- const tests = await client.prepareRun({ pipe, pipeOptions });
68
- if (!tests || tests.length === 0) {
69
- return;
70
- }
71
- const grep = ` --grep (${tests.join('|')})`;
72
- command += grep;
73
- }
74
- catch (err) {
75
- console.log(constants_js_1.APP_PREFIX, err);
66
+ const [pipe, ...optsArray] = filter.split(':');
67
+ const pipeOptions = optsArray.join(':');
68
+
69
+ try {
70
+ const tests = await client.prepareRun({ pipe, pipeOptions });
71
+
72
+ if (!tests || tests.length === 0) {
73
+ return;
76
74
  }
75
+
76
+ const grep = ` --grep (${tests.join('|')})`;
77
+ command += grep;
78
+ } catch (err) {
79
+ console.log(APP_PREFIX, err);
80
+ }
77
81
  }
82
+
78
83
  const testCmds = command.split(' ');
79
- console.log(constants_js_1.APP_PREFIX, `🚀 Running`, picocolors_1.default.green(command));
84
+ console.log(APP_PREFIX, `🚀 Running`, chalk.green(command));
85
+
80
86
  if (!apiKey) {
81
- const cmd = (0, cross_spawn_1.spawn)(testCmds[0], testCmds.slice(1), { stdio: 'inherit' });
82
- cmd.on('close', code => {
83
- console.log(constants_js_1.APP_PREFIX, '⚠️ ', `Runner exited with ${picocolors_1.default.bold(code)}, report is ignored`);
84
- if (code > exitCode)
85
- exitCode = code;
86
- process.exitCode = exitCode;
87
- });
88
- return;
87
+ const cmd = spawn(testCmds[0], testCmds.slice(1), { stdio: 'inherit' });
88
+
89
+ cmd.on('close', code => {
90
+ console.log(APP_PREFIX, '⚠️ ', `Runner exited with ${chalk.bold(code)}, report is ignored`);
91
+
92
+ if (code > exitCode) exitCode = code;
93
+ process.exitCode = exitCode;
94
+ });
95
+
96
+ return;
89
97
  }
98
+
90
99
  client.createRun().then(() => {
91
- const cmd = (0, cross_spawn_1.spawn)(testCmds[0], testCmds.slice(1), { stdio: 'inherit' });
92
- cmd.on('close', code => {
93
- const emoji = code === 0 ? '🟢' : '🔴';
94
- console.log(constants_js_1.APP_PREFIX, emoji, `Runner exited with ${picocolors_1.default.bold(code)}`);
95
- const status = code === 0 ? 'passed' : 'failed';
96
- client.updateRunStatus(status, true);
97
- if (code > exitCode)
98
- exitCode = code;
99
- process.exitCode = exitCode;
100
- });
100
+ const cmd = spawn(testCmds[0], testCmds.slice(1), { stdio: 'inherit' });
101
+
102
+ cmd.on('close', code => {
103
+ const emoji = code === 0 ? '🟢' : '🔴';
104
+ console.log(APP_PREFIX, emoji, `Runner exited with ${chalk.bold(code)}`);
105
+ const status = code === 0 ? 'passed' : 'failed';
106
+ client.updateRunStatus(status, true);
107
+
108
+ if (code > exitCode) exitCode = code;
109
+ process.exitCode = exitCode;
110
+ });
101
111
  });
102
- });
112
+ });
113
+
103
114
  if (process.argv.length <= 2) {
104
- program.outputHelp();
115
+ program.outputHelp();
105
116
  }
117
+
106
118
  program.parse(process.argv);
@@ -1,82 +1,87 @@
1
1
  #!/usr/bin/env node
2
- "use strict";
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
5
- };
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- const commander_1 = require("commander");
8
- const picocolors_1 = __importDefault(require("picocolors"));
9
- const debug_1 = __importDefault(require("debug"));
10
- const client_js_1 = __importDefault(require("../client.js"));
11
- const constants_js_1 = require("../constants.js");
12
- const utils_js_1 = require("../utils/utils.js");
13
- const config_js_1 = require("../config.js");
14
- const utils_js_2 = require("../utils/utils.js");
15
- const dotenv_1 = __importDefault(require("dotenv"));
16
- const debug = (0, debug_1.default)('@testomatio/reporter:upload-cli');
17
- const version = (0, utils_js_1.getPackageVersion)();
18
- console.log(picocolors_1.default.cyan(picocolors_1.default.bold(` 🤩 Testomat.io Reporter v${version}`)));
19
- const program = new commander_1.Command();
2
+ const { program } = require('commander');
3
+ const chalk = require('chalk');
4
+ const debug = require('debug')('@testomatio/reporter:upload-cli');
5
+ const TestomatClient = require('../client');
6
+ const { APP_PREFIX } = require('../constants');
7
+ const { version } = require('../../package.json');
8
+ const config = require('../config');
9
+ const { readLatestRunId } = require('../utils/utils');
10
+
11
+ console.log(chalk.cyan.bold(` 🤩 Testomat.io Reporter v${version}`));
12
+
20
13
  program
21
- .option('--env-file <envfile>', 'Load environment variables from env file')
22
- .option('--force', 'Re-upload artifacts even if they were uploaded before')
23
- .action(async (opts) => {
14
+ .option('--env-file <envfile>', 'Load environment variables from env file')
15
+ .option('--force', 'Re-upload artifacts even if they were uploaded before')
16
+ .action(async opts => {
24
17
  if (opts.envFile) {
25
- dotenv_1.default.config({ path: opts.envFile });
18
+ require('dotenv').config(opts.envFile); // eslint-disable-line
19
+ } else {
20
+ // try to load from env file
21
+ require('dotenv').config(); // eslint-disable-line
26
22
  }
27
- else {
28
- dotenv_1.default.config();
29
- }
30
- const apiKey = config_js_1.config.TESTOMATIO;
23
+
24
+ const apiKey = config.TESTOMATIO;
31
25
  process.env.TESTOMATIO_DISABLE_ARTIFACTS = '';
32
- const runId = process.env.TESTOMATIO_RUN || process.env.runId || (0, utils_js_2.readLatestRunId)();
26
+ const runId = process.env.TESTOMATIO_RUN || process.env.runId || readLatestRunId();
27
+
33
28
  if (!runId) {
34
- console.log('TESTOMATIO_RUN environment variable must be set or restored from a previous run.');
35
- return process.exit(1);
29
+ console.log('TESTOMATIO_RUN environment variable must be set or restored from a previous run.');
30
+ return process.exit(1);
36
31
  }
37
- const client = new client_js_1.default({
38
- apiKey,
39
- runId,
40
- isBatchEnabled: false,
32
+
33
+ const client = new TestomatClient({
34
+ apiKey,
35
+ runId,
36
+ isBatchEnabled: false,
41
37
  });
42
38
  let testruns = client.uploader.readUploadedFiles(process.env.TESTOMATIO_RUN);
39
+
43
40
  const numTotalArtifacts = testruns.length;
41
+
44
42
  debug('Found testruns:', testruns);
45
- if (!opts.force)
46
- testruns = testruns.filter(tr => !tr.uploaded);
43
+
44
+ if (!opts.force) testruns = testruns.filter(tr => !tr.uploaded);
45
+
47
46
  if (!testruns.length) {
48
- console.log(constants_js_1.APP_PREFIX, 'Total artifacts:', numTotalArtifacts);
49
- if (numTotalArtifacts) {
50
- console.log(constants_js_1.APP_PREFIX, 'No new artifacts to upload');
51
- console.log(constants_js_1.APP_PREFIX, 'To re-upload artifacts run this command with --force flag');
52
- }
53
- process.exit(0);
47
+ console.log(APP_PREFIX, 'Total artifacts:', numTotalArtifacts);
48
+ if (numTotalArtifacts) {
49
+ console.log(APP_PREFIX, 'No new artifacts to upload');
50
+ console.log(APP_PREFIX, 'To re-upload artifacts run this command with --force flag');
51
+ }
52
+ process.exit(0);
54
53
  }
54
+
55
55
  const testrunsByRid = testruns.reduce((acc, { rid, file }) => {
56
- if (!acc[rid]) {
57
- acc[rid] = [];
58
- }
59
- if (!acc[rid].includes(file))
60
- acc[rid].push(file);
61
- return acc;
56
+ if (!acc[rid]) {
57
+ acc[rid] = [];
58
+ }
59
+ if (!acc[rid].includes(file)) acc[rid].push(file);
60
+ return acc;
62
61
  }, {});
62
+
63
63
  // we need to obtain S3 credentials
64
64
  await client.createRun();
65
+
65
66
  client.uploader.checkEnabled();
66
67
  client.uploader.disableLogStorage();
68
+
67
69
  for (const rid in testrunsByRid) {
68
- const files = testrunsByRid[rid];
69
- await client.addTestRun(undefined, {
70
- rid,
71
- files,
72
- });
70
+ const files = testrunsByRid[rid];
71
+ await client.addTestRun(undefined, {
72
+ rid,
73
+ files,
74
+ });
73
75
  }
74
- console.log(constants_js_1.APP_PREFIX, client.uploader.successfulUploads.length, 'artifacts uploaded');
76
+
77
+ console.log(APP_PREFIX, client.uploader.successfulUploads.length, 'artifacts uploaded');
75
78
  if (client.uploader.failedUploads.length) {
76
- console.log(constants_js_1.APP_PREFIX, client.uploader.failedUploads.length, 'artifacts failed to upload');
79
+ console.log(APP_PREFIX, client.uploader.failedUploads.length, 'artifacts failed to upload');
77
80
  }
78
- });
81
+ });
82
+
79
83
  if (process.argv.length <= 1) {
80
- program.outputHelp();
84
+ program.outputHelp();
81
85
  }
86
+
82
87
  program.parse(process.argv);