allure 3.0.1 → 3.2.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.
@@ -4,6 +4,7 @@ import { Command, Option } from "clipanion";
4
4
  import * as console from "node:console";
5
5
  import { existsSync } from "node:fs";
6
6
  import { realpath } from "node:fs/promises";
7
+ import { isAbsolute, join } from "node:path";
7
8
  import process, { exit } from "node:process";
8
9
  import { red } from "yoctocolors";
9
10
  export class CsvCommand extends Command {
@@ -40,9 +41,9 @@ export class CsvCommand extends Command {
40
41
  const defaultCsvOptions = {
41
42
  separator: this.separator ?? ",",
42
43
  disableHeaders: this.disableHeaders ?? false,
44
+ fileName: this.output && isAbsolute(this.output) ? this.output : this.output ? join(cwd, this.output) : undefined,
43
45
  };
44
46
  const config = await readConfig(cwd, this.config, {
45
- output: this.output ?? "allure.csv",
46
47
  knownIssuesPath: this.knownIssues,
47
48
  });
48
49
  config.plugins = [
@@ -75,7 +75,7 @@ GenerateCommand.usage = Command.Usage({
75
75
  ],
76
76
  [
77
77
  "generate --stage=allure-*.zip",
78
- "Generate a report using data from any stage archive that matches the given pattern only (ignoring results directories)",
78
+ "Generate a report using data from any stage archive that matches the given pattern and results directory if it exists",
79
79
  ],
80
80
  ],
81
81
  });
@@ -9,6 +9,7 @@ export declare class QualityGateCommand extends Command {
9
9
  minTestsCount: number | undefined;
10
10
  successRate: number | undefined;
11
11
  knownIssues: string | undefined;
12
+ environment: string | undefined;
12
13
  cwd: string | undefined;
13
14
  execute(): Promise<void>;
14
15
  }
@@ -34,6 +34,9 @@ export class QualityGateCommand extends Command {
34
34
  this.knownIssues = Option.String("--known-issues", {
35
35
  description: "Path to the known issues file. Updates the file and quarantines failed tests when specified",
36
36
  });
37
+ this.environment = Option.String("--environment,--env", {
38
+ description: "Force specific environment to all tests in the run. Given environment has higher priority than the one defined in the config file (default: empty string)",
39
+ });
37
40
  this.cwd = Option.String("--cwd", {
38
41
  description: "The working directory for the command to run (default: current working directory)",
39
42
  });
@@ -41,7 +44,7 @@ export class QualityGateCommand extends Command {
41
44
  async execute() {
42
45
  const cwd = await realpath(this.cwd ?? processCwd());
43
46
  const resultsDir = (this.resultsDir ?? "./**/allure-results").replace(/[\\/]$/, "");
44
- const { maxFailures, minTestsCount, successRate, fastFail, knownIssues: knownIssuesPath } = this;
47
+ const { maxFailures, minTestsCount, successRate, fastFail, knownIssues: knownIssuesPath, environment } = this;
45
48
  const config = await readConfig(cwd, this.config, {
46
49
  knownIssuesPath,
47
50
  });
@@ -91,6 +94,7 @@ export class QualityGateCommand extends Command {
91
94
  const notHiddenTrs = trs.filter((tr) => !tr.hidden);
92
95
  const { results, fastFailed } = await allureReport.validate({
93
96
  trs: notHiddenTrs,
97
+ environment,
94
98
  knownIssues,
95
99
  state,
96
100
  });
@@ -109,6 +113,7 @@ export class QualityGateCommand extends Command {
109
113
  const validationResults = await allureReport.validate({
110
114
  trs: allTrs,
111
115
  knownIssues,
116
+ environment,
112
117
  });
113
118
  if (validationResults.results.length === 0) {
114
119
  exit(0);
@@ -7,6 +7,7 @@ import { KnownError } from "@allurereport/service";
7
7
  import { serve } from "@allurereport/static-server";
8
8
  import { Command, Option } from "clipanion";
9
9
  import * as console from "node:console";
10
+ import { randomUUID } from "node:crypto";
10
11
  import { mkdtemp, realpath, rm, writeFile } from "node:fs/promises";
11
12
  import { tmpdir } from "node:os";
12
13
  import { join, resolve } from "node:path";
@@ -16,7 +17,7 @@ import { logTests, runProcess, terminationOf } from "../utils/index.js";
16
17
  import { logError } from "../utils/logs.js";
17
18
  import { stopProcessTree } from "../utils/process.js";
18
19
  const runTests = async (params) => {
19
- const { allureReport, knownIssues, cwd, command, commandArgs, logs, environment, withQualityGate, silent } = params;
20
+ const { allureReport, knownIssues, cwd, command, commandArgs, logs, environmentVariables, environment, withQualityGate, silent, } = params;
20
21
  let testProcessStarted = false;
21
22
  const allureResultsWatchers = new Map();
22
23
  const processWatcher = delayedFileProcessingWatcher(async (path) => {
@@ -54,7 +55,7 @@ const runTests = async (params) => {
54
55
  command,
55
56
  commandArgs,
56
57
  cwd,
57
- environment,
58
+ environmentVariables,
58
59
  logs,
59
60
  });
60
61
  const qualityGateState = new QualityGateState();
@@ -72,6 +73,7 @@ const runTests = async (params) => {
72
73
  const { results, fastFailed } = await allureReport.validate({
73
74
  trs: filteredTrs,
74
75
  state: qualityGateState,
76
+ environment,
75
77
  knownIssues,
76
78
  });
77
79
  if (!fastFailed) {
@@ -161,7 +163,7 @@ export class RunCommand extends Command {
161
163
  this.stage = Option.String("--stage", {
162
164
  description: "Runs tests in stage mode to collect results to a stage archive with the provided name (default: empty string)",
163
165
  });
164
- this.environment = Option.String("--environment", {
166
+ this.environment = Option.String("--environment,--env", {
165
167
  description: "Force specific environment to all tests in the run. Given environment has higher priority than the one defined in the config file (default: empty string)",
166
168
  });
167
169
  this.historyLimit = Option.String("--history-limit", {
@@ -249,7 +251,8 @@ export class RunCommand extends Command {
249
251
  cwd,
250
252
  command,
251
253
  commandArgs,
252
- environment: {},
254
+ environment: this.environment,
255
+ environmentVariables: {},
253
256
  withQualityGate,
254
257
  });
255
258
  for (let rerun = 0; rerun < maxRerun; rerun++) {
@@ -272,7 +275,8 @@ export class RunCommand extends Command {
272
275
  cwd,
273
276
  command,
274
277
  commandArgs,
275
- environment: {
278
+ environment: this.environment,
279
+ environmentVariables: {
276
280
  ALLURE_TESTPLAN_PATH: testPlanPath,
277
281
  ALLURE_RERUN: `${rerun}`,
278
282
  },
@@ -287,6 +291,7 @@ export class RunCommand extends Command {
287
291
  const { results } = await allureReport.validate({
288
292
  trs,
289
293
  knownIssues,
294
+ environment: this.environment,
290
295
  });
291
296
  qualityGateResults = results;
292
297
  }
@@ -318,14 +323,16 @@ export class RunCommand extends Command {
318
323
  }
319
324
  const processFailed = Math.abs(globalExitCode.actual ?? globalExitCode.original) !== 0;
320
325
  if (!this.ignoreLogs && testProcessResult?.stdout) {
321
- const stdoutResultFile = new BufferResultFile(Buffer.from(testProcessResult.stdout, "utf8"), "stdout.txt");
326
+ const fileName = randomUUID();
327
+ const stdoutResultFile = new BufferResultFile(Buffer.from(testProcessResult.stdout, "utf8"), `${fileName}`);
322
328
  stdoutResultFile.contentType = "text/plain";
323
- allureReport.realtimeDispatcher.sendGlobalAttachment(stdoutResultFile);
329
+ allureReport.realtimeDispatcher.sendGlobalAttachment(stdoutResultFile, "stdout.txt");
324
330
  }
325
331
  if (!this.ignoreLogs && testProcessResult?.stderr) {
326
- const stderrResultFile = new BufferResultFile(Buffer.from(testProcessResult.stderr, "utf8"), "stderr.txt");
332
+ const fileName = randomUUID();
333
+ const stderrResultFile = new BufferResultFile(Buffer.from(testProcessResult.stderr, "utf8"), fileName);
327
334
  stderrResultFile.contentType = "text/plain";
328
- allureReport.realtimeDispatcher.sendGlobalAttachment(stderrResultFile);
335
+ allureReport.realtimeDispatcher.sendGlobalAttachment(stderrResultFile, "stderr.txt");
329
336
  if (processFailed) {
330
337
  allureReport.realtimeDispatcher.sendGlobalError({
331
338
  message: "Test process has failed",
@@ -7,6 +7,7 @@ export declare class WatchCommand extends Command {
7
7
  cwd: string | undefined;
8
8
  output: string | undefined;
9
9
  reportName: string | undefined;
10
+ open: boolean | undefined;
10
11
  port: string | undefined;
11
12
  execute(): Promise<void>;
12
13
  }
@@ -28,6 +28,9 @@ export class WatchCommand extends Command {
28
28
  this.reportName = Option.String("--report-name,--name", {
29
29
  description: "The report name (default: Allure Report)",
30
30
  });
31
+ this.open = Option.Boolean("--open", {
32
+ description: "Open the report in the default browser after generation (default: false)",
33
+ });
31
34
  this.port = Option.String("--port", {
32
35
  description: "The port to serve the reports on (default: random port)",
33
36
  });
@@ -46,6 +49,8 @@ export class WatchCommand extends Command {
46
49
  const config = await readConfig(this.cwd, this.config, {
47
50
  output: this.output,
48
51
  name: this.reportName,
52
+ open: this.open,
53
+ port: this.port,
49
54
  });
50
55
  try {
51
56
  await rm(config.output, { recursive: true });
@@ -71,7 +76,9 @@ export class WatchCommand extends Command {
71
76
  {
72
77
  id: "awesome",
73
78
  enabled: true,
74
- options: {},
79
+ options: {
80
+ open: config.open,
81
+ },
75
82
  plugin: new Awesome({
76
83
  reportName: config.name,
77
84
  }),
@@ -102,9 +109,6 @@ export class WatchCommand extends Command {
102
109
  if (pluginIdToOpen) {
103
110
  await server.open(join(server.url, pluginIdToOpen));
104
111
  }
105
- else {
106
- await server.open(server.url);
107
- }
108
112
  console.info("Press Ctrl+C to exit");
109
113
  process.on("SIGINT", async () => {
110
114
  console.log("");
@@ -11,7 +11,7 @@ export declare const runProcess: (params: {
11
11
  command: string;
12
12
  commandArgs: string[];
13
13
  cwd: string | undefined;
14
- environment?: Record<string, string>;
14
+ environmentVariables?: Record<string, string>;
15
15
  logs?: "pipe" | "inherit" | "ignore";
16
16
  }) => ChildProcess;
17
17
  export declare const terminationOf: (testProcess: ChildProcess) => Promise<number | null>;
@@ -5,10 +5,10 @@ import { platform } from "process";
5
5
  const IS_WIN = platform === "win32";
6
6
  const PS_OUTPUT_PATTERN = /(?<ppid>\d+)\s+(?<pid>\d+)\s+(?<comm>.*)/;
7
7
  export const runProcess = (params) => {
8
- const { command, commandArgs, cwd, environment = {}, logs = "inherit" } = params;
8
+ const { command, commandArgs, cwd, environmentVariables = {}, logs = "inherit" } = params;
9
9
  const env = {
10
10
  ...process.env,
11
- ...environment,
11
+ ...environmentVariables,
12
12
  };
13
13
  if (logs === "pipe") {
14
14
  Object.assign(env, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "allure",
3
- "version": "3.0.1",
3
+ "version": "3.2.0",
4
4
  "description": "Allure Commandline Tool",
5
5
  "keywords": [
6
6
  "allure",
@@ -32,25 +32,25 @@
32
32
  "test": "vitest run"
33
33
  },
34
34
  "dependencies": {
35
- "@allurereport/charts-api": "3.0.1",
36
- "@allurereport/ci": "3.0.1",
37
- "@allurereport/core": "3.0.1",
38
- "@allurereport/core-api": "3.0.1",
39
- "@allurereport/directory-watcher": "3.0.1",
40
- "@allurereport/plugin-allure2": "3.0.1",
41
- "@allurereport/plugin-api": "3.0.1",
42
- "@allurereport/plugin-awesome": "3.0.1",
43
- "@allurereport/plugin-classic": "3.0.1",
44
- "@allurereport/plugin-csv": "3.0.1",
45
- "@allurereport/plugin-dashboard": "3.0.1",
46
- "@allurereport/plugin-jira": "3.0.1",
47
- "@allurereport/plugin-log": "3.0.1",
48
- "@allurereport/plugin-progress": "3.0.1",
49
- "@allurereport/plugin-server-reload": "3.0.1",
50
- "@allurereport/plugin-slack": "3.0.1",
51
- "@allurereport/reader-api": "3.0.1",
52
- "@allurereport/service": "3.0.1",
53
- "@allurereport/static-server": "3.0.1",
35
+ "@allurereport/charts-api": "3.2.0",
36
+ "@allurereport/ci": "3.2.0",
37
+ "@allurereport/core": "3.2.0",
38
+ "@allurereport/core-api": "3.2.0",
39
+ "@allurereport/directory-watcher": "3.2.0",
40
+ "@allurereport/plugin-allure2": "3.2.0",
41
+ "@allurereport/plugin-api": "3.2.0",
42
+ "@allurereport/plugin-awesome": "3.2.0",
43
+ "@allurereport/plugin-classic": "3.2.0",
44
+ "@allurereport/plugin-csv": "3.2.0",
45
+ "@allurereport/plugin-dashboard": "3.2.0",
46
+ "@allurereport/plugin-jira": "3.2.0",
47
+ "@allurereport/plugin-log": "3.2.0",
48
+ "@allurereport/plugin-progress": "3.2.0",
49
+ "@allurereport/plugin-server-reload": "3.2.0",
50
+ "@allurereport/plugin-slack": "3.2.0",
51
+ "@allurereport/reader-api": "3.2.0",
52
+ "@allurereport/service": "3.2.0",
53
+ "@allurereport/static-server": "3.2.0",
54
54
  "adm-zip": "^0.5.16",
55
55
  "clipanion": "^4.0.0-rc.4",
56
56
  "glob": "^11.1.0",