@testomatio/reporter 0.6.1 → 0.6.4

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,3 +1,16 @@
1
+ # 0.6.4
2
+
3
+ * Added `TESTOMATIO_PROCEED=1` param to not close current run
4
+ * Fixed priority of commands from `npx @testomatio/reporter`
5
+
6
+ # 0.6.3
7
+
8
+ * Fixed `npx start-test-run` to launch commands
9
+
10
+ # 0.6.2
11
+
12
+ * Added `--env-file` option to load env variables from env file
13
+
1
14
  # 0.6.1
2
15
 
3
16
  * Fixed creating RunGroup with JUnit reporter
package/README.md CHANGED
@@ -54,6 +54,9 @@ TESTOMATIO={API_KEY} npx start-test-run -c 'npx codeceptjs run-workers 2'
54
54
 
55
55
  > Specify a command to run with `-c` option in `start-test-run`
56
56
 
57
+ Use `--env-file <envfile>` option to load environment variables from .env file. Inside env file TESTOMATIO credentials like `TESTOMATIO` api key or [S3 config](#attaching-test-artifacts) can be stored.
58
+
59
+
57
60
  ### Playwright
58
61
 
59
62
  Add a reporter to Playwright config:
@@ -165,7 +168,7 @@ exports.config = {
165
168
  Run the following command from you project folder:
166
169
 
167
170
  ```bash
168
- TESTOMATIO={API_KEY} npx @testomatio/reporter@latest -c 'npx protractor conf.js'
171
+ TESTOMATIO={API_KEY} npx start-test-run@latest -c 'npx protractor conf.js'
169
172
  ```
170
173
 
171
174
  ### WebdriverIO
@@ -202,7 +205,7 @@ For making screenshots on failed tests add the following hook to `wdio.conf.js`:
202
205
  Run the following command from you project folder:
203
206
 
204
207
  ```bash
205
- TESTOMATIO={API_KEY} npx @testomatio/reporter -c 'npx wdio wdio.conf.js'
208
+ TESTOMATIO={API_KEY} npx start-test-run -c 'npx wdio wdio.conf.js'
206
209
  ```
207
210
 
208
211
  ## JUnit Reports
@@ -248,6 +251,7 @@ TESTOMATIO={API_KEY} npx report-xml "{pattern}" --lang={lang}
248
251
  * `pattern` - is a glob pattern to match all XML files from report. For instance, `"test/report/**.xml"` or just `report.xml`
249
252
  * `--lang` option can be specified to identify source code of the project. Example: `--lang=Ruby` or `--lang=Java` or `--lang=Python`.
250
253
  * `--java-tests` option is avaiable for Java projects, and can be set if path to tests is different then `src/test/java`. When this option is enable, `lang` option is automatically set to `java`
254
+ * `--env-file <envfile>` option to load environment variables from .env file. Inside env file TESTOMATIO credentials like `TESTOMATIO` api key or [S3 config](#attaching-test-artifacts) can be stored.
251
255
 
252
256
 
253
257
  > *Notice:* All options from [Advanced Usage](#advanced-usage) are also available for JUnit reporter
@@ -345,8 +349,7 @@ Testomat.io will not create tests from the report if they have not been previous
345
349
  TESTOMATIO={API_KEY} TESTOMATIO_CREATE=1 <actual run command>
346
350
  ```
347
351
 
348
-
349
- ### Adding Report to Run by ID
352
+ ### Add Report to Run by ID
350
353
 
351
354
  This feature is widely used when a run is executed on CI.
352
355
  A run is created before the test is started and it is marked as `scheduled`. Then
@@ -356,6 +359,21 @@ a report is assigned to that run using `TESTOMATIO_RUN` environment variable and
356
359
  TESTOMATIO={API_KEY} TESTOMATIO_RUN={RUN_ID} <actual run command>
357
360
  ```
358
361
 
362
+ ### Do Not Finalize Run
363
+
364
+ If multiple reports are added to the same run, each of them should not finalize the run.
365
+ In this case use `TESTOMATIO_PROCEED=1` environment variable, so the Run will be shown as `Running`
366
+
367
+ ```
368
+ TESTOMATIO={API_KEY} TESTOMATIO_PROCEED=1 TESTOMATIO_RUN={RUN_ID} <actual run command>
369
+ ```
370
+
371
+ After all reports were attached and run can be execute the following command:
372
+
373
+ ```
374
+ TESTOMATIO={API_KEY} TESTOMATIO_RUN={RUN_ID} npx start-test-run --finish
375
+ ```
376
+
359
377
  ### Setting Report Title
360
378
 
361
379
  Give a title to your reports by passing it as environment variable to `TESTOMATIO_TITLE`.
@@ -438,7 +456,14 @@ S3_FORCE_PATH_STYLE=true
438
456
 
439
457
  > It is important to add S3_FORCE_PATH_STYLE var for minio setup
440
458
 
441
- For local testing, it is recommended to store this configuration in `.env` file and load it with [dotenv](https://www.npmjs.com/package/dotenv) library.
459
+ For local testing, it is recommended to store configuration in `.env` file. If you load configuration from a test runner, use [dotenv](https://www.npmjs.com/package/dotenv) library to load it.
460
+
461
+ If you run a reporter via `start-test-run` or `report-xml` command use `--env-file` option to load variables from .env file:
462
+
463
+ ```
464
+ npx start-test-run --env-file .env
465
+ npx report-xml --env-file .env
466
+ ```
442
467
 
443
468
  On CI set environment variables in CI config.
444
469
 
@@ -471,7 +496,7 @@ TESTOMATIO_DISABLE_ARTIFACTS=1
471
496
  If you want to create a run and obtain its `{RUN_ID}` from [testomat.io](https://testomat.io) you can use `--launch` option:
472
497
 
473
498
  ```bash
474
- TESTOMATIO={API_KEY} npx @testomatio/reporter@latest --launch
499
+ TESTOMATIO={API_KEY} npx start-test-run@latest --launch
475
500
  ```
476
501
 
477
502
  This command will return `{RUN_ID}` which you can pass to other testrunner processes.
@@ -483,5 +508,5 @@ This command will return `{RUN_ID}` which you can pass to other testrunner proce
483
508
  If you want to finish a run started by `--launch` use `--finish` option. `TESTOMATIO_RUN` environment variable is required:
484
509
 
485
510
  ```bash
486
- TESTOMATIO={API_KEY} TESTOMATIO_RUN={RUN_ID} npx @testomatio/reporter@latest --finish
511
+ TESTOMATIO={API_KEY} TESTOMATIO_RUN={RUN_ID} npx start-test-run@latest --finish
487
512
  ```
@@ -1,32 +1,33 @@
1
1
  #!/usr/bin/env node
2
2
  const program = require("commander");
3
- // const chalk = require("chalk");
3
+ const chalk = require("chalk");
4
4
  const glob = require('glob');
5
5
 
6
6
  const { APP_PREFIX } = require('../constants');
7
7
  const XmlReader = require("../xmlReader");
8
8
 
9
- // const apiKey = process.env['INPUT_TESTOMATIO-KEY'] || process.env.TESTOMATIO;
10
- // const title = process.env.TESTOMATIO_TITLE;
9
+ const { version } = require('../../package.json');
11
10
 
12
- // console.log(chalk.cyan.bold(` 🤩 xmlReader by Testomat.io v${version}`));
11
+ console.log(chalk.cyan.bold(` 🤩 Testomat.io XML Reporter v${version}`));
13
12
 
14
13
  program
15
14
  .arguments("<pattern>")
16
15
  .option("-d, --dir <dir>", "Project directory")
17
16
  .option("--java-tests [java-path]", "Load Java tests from path, by default: src/test/java")
18
17
  .option("--lang <lang>", "Language used (python, ruby, java)")
18
+ .option("--env-file <envfile>", "Load environment variables from env file")
19
19
  .action(async (pattern, opts) => {
20
20
  if (!pattern.endsWith('.xml')) {
21
21
  pattern += '.xml';
22
22
  }
23
23
  let { javaTests, lang } = opts;
24
+ if (opts.envFile) require('dotenv').config(opts.envFile); // eslint-disable-line
24
25
  if (javaTests === true) javaTests = 'src/test/java';
25
26
  lang = lang?.toLowerCase();
26
27
  const runReader = new XmlReader({ javaTests, lang });
27
28
  const files = glob.sync(pattern, { cwd: opts.dir || process.cwd() });
28
29
  if (!files.length) {
29
- console.log(APP_PREFIX,`Report can't be created. No XML files found 😥`);
30
+ console.log(APP_PREFIX, `Report can't be created. No XML files found 😥`);
30
31
  process.exitCode = 1;
31
32
  return;
32
33
  }
@@ -40,11 +41,11 @@ program
40
41
  await runReader.uploadData();
41
42
  } catch (err) {
42
43
  console.log(APP_PREFIX, 'Error updating status, skipping...', err);
44
+ process.exitCode = 1;
43
45
  }
44
46
  });
45
47
 
46
-
47
- if (process.argv.length < 1) {
48
+ if (process.argv.length < 3) {
48
49
  program.outputHelp();
49
50
  }
50
51
 
@@ -4,16 +4,22 @@ const program = require('commander');
4
4
  const chalk = require('chalk');
5
5
  const TestomatClient = require('../client');
6
6
  const { APP_PREFIX, FINISHED } = require('../constants');
7
+ const { version } = require('../../package.json');
7
8
 
8
- const apiKey = process.env['INPUT_TESTOMATIO-KEY'] || process.env.TESTOMATIO;
9
- const title = process.env.TESTOMATIO_TITLE;
9
+ console.log(chalk.cyan.bold(` 🤩 Testomat.io Reporter v${version}`));
10
10
 
11
11
  program
12
12
  .option('-c, --command <cmd>', 'Test runner command')
13
13
  .option('--launch', 'Start a new run and return its ID')
14
14
  .option('--finish', 'Finish Run by its ID')
15
+ .option("--env-file <envfile>", "Load environment variables from env file")
15
16
  .action(opts => {
17
+
16
18
  const { command, launch, finish } = opts;
19
+ if (opts.envFile) require('dotenv').config(opts.envFile); // eslint-disable-line
20
+
21
+ const apiKey = process.env['INPUT_TESTOMATIO-KEY'] || process.env.TESTOMATIO;
22
+ const title = process.env.TESTOMATIO_TITLE;
17
23
 
18
24
  if (launch) {
19
25
  console.log('Starting a new Run on Testomat.io...');
@@ -45,6 +51,12 @@ program
45
51
 
46
52
  let exitCode = 0;
47
53
 
54
+ if (!command.split) {
55
+ process.exitCode = 255;
56
+ console.log(APP_PREFIX, `No command provided. Use -c option to launch a test runner.`);
57
+ return;
58
+ }
59
+
48
60
  const testCmds = command.split(' ');
49
61
  console.log(APP_PREFIX, `🚀 Running`, chalk.green(command));
50
62
 
package/lib/client.js CHANGED
@@ -24,7 +24,8 @@ class TestomatClient {
24
24
  constructor(params) {
25
25
  this.apiKey = params.apiKey || process.env.TESTOMATIO;
26
26
  this.title = params.title || process.env.TESTOMATIO_TITLE;
27
- this.createNewTests = !!process.env.TESTOMATIO_CREATE
27
+ this.createNewTests = !!process.env.TESTOMATIO_CREATE;
28
+ this.proceed = process.env.TESTOMATIO_PROCEED;
28
29
  this.env = TESTOMATIO_ENV;
29
30
  this.parallel = params.parallel;
30
31
  this.runId = process.env.runId;
@@ -197,7 +198,7 @@ class TestomatClient {
197
198
  updateRunStatus(status, isParallel) {
198
199
  this.queue = this.queue
199
200
  .then(async () => {
200
- if (this.runId) {
201
+ if (this.runId && !this.proceed) {
201
202
  let statusEvent;
202
203
  if (status === FINISHED) statusEvent = 'finish';
203
204
  if (status === PASSED) statusEvent = 'pass';
@@ -221,6 +222,11 @@ class TestomatClient {
221
222
  );
222
223
  }
223
224
  }
225
+ if (this.runUrl && this.proceed) {
226
+ const notFinishedMessage = chalk.yellow.bold('Run was not finished because of $TESTOMATIO_PROCEED');
227
+ console.log(APP_PREFIX, `📊 ${notFinishedMessage}. Report URL: ${chalk.magenta(this.runUrl)}`);
228
+ console.log(APP_PREFIX, `🛬 Run to finish it: TESTOMATIO_RUN=${this.runId} npx start-test-run --finish`);
229
+ }
224
230
  })
225
231
  .catch(err => {
226
232
  console.log(APP_PREFIX, 'Error updating status, skipping...', err);
package/lib/xmlReader.js CHANGED
@@ -202,6 +202,8 @@ class XmlReader {
202
202
  group_title: this.requestParams.group_title,
203
203
  };
204
204
 
205
+ if (process.env.DEBUG) console.log("Run", runParams);
206
+
205
207
  try {
206
208
  const resp = await this.axios.post(this.url, runParams, {
207
209
  maxContentLength: Infinity,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testomatio/reporter",
3
- "version": "0.6.1",
3
+ "version": "0.6.4",
4
4
  "description": "Testomatio Reporter Client",
5
5
  "main": "./lib/reporter.js",
6
6
  "repository": "git@github.com:testomatio/reporter.git",
@@ -12,6 +12,7 @@
12
12
  "callsite-record": "^4.1.4",
13
13
  "chalk": "^4.1.0",
14
14
  "commander": "^4.1.1",
15
+ "dotenv": "^16.0.1",
15
16
  "fast-xml-parser": "^4.0.8",
16
17
  "glob": "^8.0.3",
17
18
  "has-flag": "^5.0.1",
@@ -53,7 +54,7 @@
53
54
  "puppeteer": "^13.1.2"
54
55
  },
55
56
  "bin": {
56
- "start-test-run": "./lib/bin/startTest.js",
57
- "report-xml": "./lib/bin/reportXml.js"
57
+ "report-xml": "./lib/bin/reportXml.js",
58
+ "start-test-run": "./lib/bin/startTest.js"
58
59
  }
59
60
  }