@testomatio/reporter 0.6.1 → 0.6.2

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,7 @@
1
+ # 0.6.2
2
+
3
+ * Added `--env-file` option to load env variables from env file
4
+
1
5
  # 0.6.1
2
6
 
3
7
  * 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:
@@ -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
@@ -438,7 +442,14 @@ S3_FORCE_PATH_STYLE=true
438
442
 
439
443
  > It is important to add S3_FORCE_PATH_STYLE var for minio setup
440
444
 
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.
445
+ 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.
446
+
447
+ If you run a reporter via `start-test-run` or `report-xml` command use `--env-file` option to load variables from .env file:
448
+
449
+ ```
450
+ npx start-test-run --env-file .env
451
+ npx report-xml --env-file .env
452
+ ```
442
453
 
443
454
  On CI set environment variables in CI config.
444
455
 
@@ -1,32 +1,32 @@
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;
11
-
12
- // console.log(chalk.cyan.bold(` 🤩 xmlReader by Testomat.io v${version}`));
9
+ const { version } = require('../../package.json');
10
+ console.log(chalk.cyan.bold(` 🤩 Testomat.io XML Reporter v${version}`));
13
11
 
14
12
  program
15
13
  .arguments("<pattern>")
16
14
  .option("-d, --dir <dir>", "Project directory")
17
15
  .option("--java-tests [java-path]", "Load Java tests from path, by default: src/test/java")
18
16
  .option("--lang <lang>", "Language used (python, ruby, java)")
17
+ .option("--env-file <envfile>", "Load environment variables from env file")
19
18
  .action(async (pattern, opts) => {
20
19
  if (!pattern.endsWith('.xml')) {
21
20
  pattern += '.xml';
22
21
  }
23
22
  let { javaTests, lang } = opts;
23
+ if (opts.envFile) require('dotenv').config(opts.envFile);
24
24
  if (javaTests === true) javaTests = 'src/test/java';
25
25
  lang = lang?.toLowerCase();
26
26
  const runReader = new XmlReader({ javaTests, lang });
27
27
  const files = glob.sync(pattern, { cwd: opts.dir || process.cwd() });
28
28
  if (!files.length) {
29
- console.log(APP_PREFIX,`Report can't be created. No XML files found 😥`);
29
+ console.log(APP_PREFIX, `Report can't be created. No XML files found 😥`);
30
30
  process.exitCode = 1;
31
31
  return;
32
32
  }
@@ -40,11 +40,11 @@ program
40
40
  await runReader.uploadData();
41
41
  } catch (err) {
42
42
  console.log(APP_PREFIX, 'Error updating status, skipping...', err);
43
+ process.exitCode = 1;
43
44
  }
44
45
  });
45
46
 
46
-
47
- if (process.argv.length < 1) {
47
+ if (process.argv.length < 3) {
48
48
  program.outputHelp();
49
49
  }
50
50
 
@@ -5,15 +5,22 @@ const chalk = require('chalk');
5
5
  const TestomatClient = require('../client');
6
6
  const { APP_PREFIX, FINISHED } = require('../constants');
7
7
 
8
- const apiKey = process.env['INPUT_TESTOMATIO-KEY'] || process.env.TESTOMATIO;
9
- const title = process.env.TESTOMATIO_TITLE;
8
+ const { version } = require('../../package.json');
9
+ console.log(chalk.cyan.bold(` 🤩 Testomat.io Reporter v${version}`));
10
+
10
11
 
11
12
  program
12
13
  .option('-c, --command <cmd>', 'Test runner command')
13
14
  .option('--launch', 'Start a new run and return its ID')
14
15
  .option('--finish', 'Finish Run by its ID')
16
+ .option("--env-file <envfile>", "Load environment variables from env file")
15
17
  .action(opts => {
18
+
16
19
  const { command, launch, finish } = opts;
20
+ if (opts.envFile) require('dotenv').config(opts.envFile);
21
+
22
+ const apiKey = process.env['INPUT_TESTOMATIO-KEY'] || process.env.TESTOMATIO;
23
+ const title = process.env.TESTOMATIO_TITLE;
17
24
 
18
25
  if (launch) {
19
26
  console.log('Starting a new Run on Testomat.io...');
@@ -45,6 +52,7 @@ program
45
52
 
46
53
  let exitCode = 0;
47
54
 
55
+ if (command) return;
48
56
  const testCmds = command.split(' ');
49
57
  console.log(APP_PREFIX, `🚀 Running`, chalk.green(command));
50
58
 
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.2",
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",