allure 3.1.0 → 3.3.1

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.
@@ -3,5 +3,5 @@ export declare const generate: (params: {
3
3
  cwd: string;
4
4
  config: FullConfig;
5
5
  resultsDir: string;
6
- stage?: string[];
6
+ dump?: string[];
7
7
  }) => Promise<void>;
@@ -5,21 +5,21 @@ import { exit } from "node:process";
5
5
  import { red } from "yoctocolors";
6
6
  import { logError } from "../../utils/logs.js";
7
7
  export const generate = async (params) => {
8
- const stageDumpFiles = [];
8
+ const dumpFiles = [];
9
9
  const resultsDirectories = [];
10
- if (params?.stage?.length) {
11
- for (const stage of params.stage) {
12
- const matchedFiles = await glob(stage, {
10
+ if (params?.dump?.length) {
11
+ for (const dump of params.dump) {
12
+ const matchedFiles = await glob(dump, {
13
13
  nodir: true,
14
14
  dot: true,
15
15
  absolute: true,
16
16
  windowsPathsNoEscape: true,
17
17
  cwd: params.cwd,
18
18
  });
19
- stageDumpFiles.push(...matchedFiles);
19
+ dumpFiles.push(...matchedFiles);
20
20
  }
21
21
  }
22
- if (!!params?.resultsDir || stageDumpFiles.length === 0) {
22
+ if (!!params?.resultsDir || dumpFiles.length === 0) {
23
23
  const matchedDirs = (await glob(params.resultsDir, {
24
24
  mark: true,
25
25
  nodir: false,
@@ -30,14 +30,14 @@ export const generate = async (params) => {
30
30
  })).filter((p) => /(\/|\\)$/.test(p));
31
31
  resultsDirectories.push(...matchedDirs);
32
32
  }
33
- if (resultsDirectories.length === 0 && stageDumpFiles.length === 0) {
33
+ if (resultsDirectories.length === 0 && dumpFiles.length === 0) {
34
34
  console.error(red(`No test results directories found matching pattern: ${params.resultsDir}`));
35
35
  exit(1);
36
36
  return;
37
37
  }
38
38
  try {
39
39
  const allureReport = new AllureReport(params.config);
40
- await allureReport.restoreState(Array.from(stageDumpFiles));
40
+ await allureReport.restoreState(Array.from(dumpFiles));
41
41
  await allureReport.start();
42
42
  for (const dir of resultsDirectories) {
43
43
  await allureReport.readDirectory(dir);
@@ -7,7 +7,7 @@ export declare class GenerateCommand extends Command {
7
7
  output: string | undefined;
8
8
  cwd: string | undefined;
9
9
  reportName: string | undefined;
10
- stage: string[] | undefined;
10
+ dump: string[] | undefined;
11
11
  open: boolean | undefined;
12
12
  port: string | undefined;
13
13
  historyLimit: string | undefined;
@@ -22,8 +22,8 @@ export class GenerateCommand extends Command {
22
22
  this.reportName = Option.String("--report-name,--name", {
23
23
  description: "The report name (default: Allure Report)",
24
24
  });
25
- this.stage = Option.Array("--stage", {
26
- description: "Stages archives to restore state from (default: empty string)",
25
+ this.dump = Option.Array("--dump", {
26
+ description: "Dump archives to restore state from (default: empty string)",
27
27
  });
28
28
  this.open = Option.Boolean("--open", {
29
29
  description: "Open the report in the default browser after generation (default: false)",
@@ -45,7 +45,7 @@ export class GenerateCommand extends Command {
45
45
  historyLimit: this.historyLimit ? parseInt(this.historyLimit, 10) : undefined,
46
46
  });
47
47
  await generate({
48
- stage: this.stage,
48
+ dump: this.dump,
49
49
  resultsDir: this.resultsDir ?? "./**/allure-results",
50
50
  cwd,
51
51
  config,
@@ -70,12 +70,12 @@ GenerateCommand.usage = Command.Usage({
70
70
  "Generate a report from the ./allure-results directory to the custom-report directory",
71
71
  ],
72
72
  [
73
- "generate --stage=windows.zip --stage=macos.zip ./allure-results",
73
+ "generate --dump=windows.zip --dump=macos.zip ./allure-results",
74
74
  "Generate a report using data from windows.zip and macos.zip archives and using results from the ./allure-results directory",
75
75
  ],
76
76
  [
77
- "generate --stage=allure-*.zip",
78
- "Generate a report using data from any stage archive that matches the given pattern only (ignoring results directories)",
77
+ "generate --dump=allure-*.zip",
78
+ "Generate a report using data from any dump 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);
@@ -18,7 +18,7 @@ export declare class RunCommand extends Command {
18
18
  rerun: string | undefined;
19
19
  silent: boolean | undefined;
20
20
  ignoreLogs: boolean | undefined;
21
- stage: string | undefined;
21
+ dump: string | undefined;
22
22
  environment: string | undefined;
23
23
  historyLimit: string | undefined;
24
24
  commandToRun: string[];
@@ -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) {
@@ -158,10 +160,10 @@ export class RunCommand extends Command {
158
160
  this.ignoreLogs = Option.Boolean("--ignore-logs", {
159
161
  description: "Prevent logs attaching to the report (default: false)",
160
162
  });
161
- this.stage = Option.String("--stage", {
162
- description: "Runs tests in stage mode to collect results to a stage archive with the provided name (default: empty string)",
163
+ this.dump = Option.String("--dump", {
164
+ description: "Runs tests in dump mode to collect results to a dump 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", {
@@ -215,7 +217,7 @@ export class RunCommand extends Command {
215
217
  const allureReport = new AllureReport({
216
218
  ...config,
217
219
  environment: this.environment,
218
- stage: this.stage,
220
+ dump: this.dump,
219
221
  realTime: false,
220
222
  plugins: [
221
223
  ...(config.plugins?.length
@@ -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",
@@ -355,8 +362,8 @@ RunCommand.usage = Command.Usage({
355
362
  ["run -- npm run test", "Run npm run test and collect Allure results"],
356
363
  ["run --rerun 3 -- npm run test", "Run npm run test and rerun failed tests up to 3 times"],
357
364
  [
358
- "run --stage=my-stage -- npm run test",
359
- "Run npm run test and pack inner report state into my-stage.zip archive to restore the state in the next run",
365
+ "run --dump=my-dump -- npm run test",
366
+ "Run npm run test and pack inner report state into my-dump.zip archive to restore the state in the next run",
360
367
  ],
361
368
  ],
362
369
  });
@@ -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.1.0",
3
+ "version": "3.3.1",
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.1.0",
36
- "@allurereport/ci": "3.1.0",
37
- "@allurereport/core": "3.1.0",
38
- "@allurereport/core-api": "3.1.0",
39
- "@allurereport/directory-watcher": "3.1.0",
40
- "@allurereport/plugin-allure2": "3.1.0",
41
- "@allurereport/plugin-api": "3.1.0",
42
- "@allurereport/plugin-awesome": "3.1.0",
43
- "@allurereport/plugin-classic": "3.1.0",
44
- "@allurereport/plugin-csv": "3.1.0",
45
- "@allurereport/plugin-dashboard": "3.1.0",
46
- "@allurereport/plugin-jira": "3.1.0",
47
- "@allurereport/plugin-log": "3.1.0",
48
- "@allurereport/plugin-progress": "3.1.0",
49
- "@allurereport/plugin-server-reload": "3.1.0",
50
- "@allurereport/plugin-slack": "3.1.0",
51
- "@allurereport/reader-api": "3.1.0",
52
- "@allurereport/service": "3.1.0",
53
- "@allurereport/static-server": "3.1.0",
35
+ "@allurereport/charts-api": "3.3.1",
36
+ "@allurereport/ci": "3.3.1",
37
+ "@allurereport/core": "3.3.1",
38
+ "@allurereport/core-api": "3.3.1",
39
+ "@allurereport/directory-watcher": "3.3.1",
40
+ "@allurereport/plugin-allure2": "3.3.1",
41
+ "@allurereport/plugin-api": "3.3.1",
42
+ "@allurereport/plugin-awesome": "3.3.1",
43
+ "@allurereport/plugin-classic": "3.3.1",
44
+ "@allurereport/plugin-csv": "3.3.1",
45
+ "@allurereport/plugin-dashboard": "3.3.1",
46
+ "@allurereport/plugin-jira": "3.3.1",
47
+ "@allurereport/plugin-log": "3.3.1",
48
+ "@allurereport/plugin-progress": "3.3.1",
49
+ "@allurereport/plugin-server-reload": "3.3.1",
50
+ "@allurereport/plugin-slack": "3.3.1",
51
+ "@allurereport/reader-api": "3.3.1",
52
+ "@allurereport/service": "3.3.1",
53
+ "@allurereport/static-server": "3.3.1",
54
54
  "adm-zip": "^0.5.16",
55
55
  "clipanion": "^4.0.0-rc.4",
56
56
  "glob": "^11.1.0",