@testomatio/reporter 0.6.0 → 0.6.3

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,19 @@
1
+ # 0.6.3
2
+
3
+ * Fixed `npx start-test-run` to launch commands
4
+
5
+ # 0.6.2
6
+
7
+ * Added `--env-file` option to load env variables from env file
8
+
9
+ # 0.6.1
10
+
11
+ * Fixed creating RunGroup with JUnit reporter
12
+
13
+ # 0.6.0
14
+
15
+ * JUnit reporter support
16
+
1
17
  # 0.5.10
2
18
 
3
19
  * Fixed reporting Scenario Outline in Cypress-Cucumber
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:
@@ -246,8 +249,9 @@ TESTOMATIO={API_KEY} npx report-xml "{pattern}" --lang={lang}
246
249
  ```
247
250
 
248
251
  * `pattern` - is a glob pattern to match all XML files from report. For instance, `"test/report/**.xml"` or just `report.xml`
249
- * `--lang` option should be specified to identify source code of the project. Example: `--lang=Ruby` or `--lang=Java` or `--lang=Python`.
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
@@ -273,7 +277,7 @@ TESTOMATIO={API_KEY} npx report-xml report.xml --lang=python
273
277
  Run tests via Maven, make sure JUnit report was configured in `pom.xml`.
274
278
 
275
279
  ```
276
- maven clean test
280
+ mvn clean test
277
281
  ```
278
282
 
279
283
  Import report with this command:
@@ -308,6 +312,33 @@ Import reports from `test/reports` directory:
308
312
  TESTOMATIO={API_KEY} npx report-xml "test/reports/*.xml" --lang ruby
309
313
  ```
310
314
 
315
+ ### Artifacts
316
+
317
+ Screenshots or videos from tests are uploaded if a test contains output with a path to file of following format:
318
+
319
+ ```
320
+ file://path/to/screenshot.png
321
+ ```
322
+
323
+ For instance, inside Java test you can use `System.out.println` to print a path to file that should be uploaded as a screenshot.
324
+
325
+ ```java
326
+ System.out.println("file://" + pathToScreenshot);
327
+ ```
328
+
329
+ This will produce XML report which contains path to a file:
330
+
331
+ ```xml
332
+ <testcase>
333
+ <system-out><![CDATA[
334
+ file://path/to/scrrenshot.png
335
+ ]]></system-out>
336
+ </testcase>
337
+ ```
338
+
339
+ When uploaded XML report, all files from `file://` will be uploaded to corresponding tests.
340
+
341
+
311
342
  ## Advanced Usage
312
343
 
313
344
  ### Create Unmatched Tests
@@ -411,7 +442,14 @@ S3_FORCE_PATH_STYLE=true
411
442
 
412
443
  > It is important to add S3_FORCE_PATH_STYLE var for minio setup
413
444
 
414
- 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
+ ```
415
453
 
416
454
  On CI set environment variables in CI config.
417
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,12 @@ program
45
52
 
46
53
  let exitCode = 0;
47
54
 
55
+ if (!command.split) {
56
+ process.exitCode = 255;
57
+ console.log(APP_PREFIX, `No command provided. Use -c option to launch a test runner.`);
58
+ return;
59
+ }
60
+
48
61
  const testCmds = command.split(' ');
49
62
  console.log(APP_PREFIX, `🚀 Running`, chalk.green(command));
50
63
 
package/lib/xmlReader.js CHANGED
@@ -199,9 +199,11 @@ class XmlReader {
199
199
  api_key: this.requestParams.apiKey,
200
200
  title: this.requestParams.title,
201
201
  env: this.requestParams.env,
202
- group_title: this.requestParams.runGroup,
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.0",
3
+ "version": "0.6.3",
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",