allure 3.0.0-beta.2 → 3.0.0-beta.21
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/README.md +148 -16
- package/dist/commands/allure2.d.ts +15 -0
- package/dist/commands/allure2.js +77 -0
- package/dist/commands/awesome.d.ts +18 -12
- package/dist/commands/awesome.js +83 -75
- package/dist/commands/classic.d.ts +15 -11
- package/dist/commands/classic.js +71 -63
- package/dist/commands/csv.d.ts +13 -9
- package/dist/commands/csv.js +63 -45
- package/dist/commands/dashboard.d.ts +15 -0
- package/dist/commands/dashboard.js +77 -0
- package/dist/commands/generate.d.ts +12 -9
- package/dist/commands/generate.js +98 -26
- package/dist/commands/history.d.ts +9 -7
- package/dist/commands/history.js +32 -29
- package/dist/commands/index.d.ts +8 -0
- package/dist/commands/index.js +8 -0
- package/dist/commands/jira/clear.d.ts +16 -0
- package/dist/commands/jira/clear.js +113 -0
- package/dist/commands/jira/index.d.ts +1 -0
- package/dist/commands/jira/index.js +1 -0
- package/dist/commands/knownIssue.d.ts +8 -6
- package/dist/commands/knownIssue.js +31 -20
- package/dist/commands/log.d.ts +12 -7
- package/dist/commands/log.js +58 -40
- package/dist/commands/login.d.ts +8 -0
- package/dist/commands/login.js +50 -0
- package/dist/commands/logout.d.ts +8 -0
- package/dist/commands/logout.js +50 -0
- package/dist/commands/open.d.ts +11 -8
- package/dist/commands/open.js +36 -36
- package/dist/commands/projects/create.d.ts +9 -0
- package/dist/commands/projects/create.js +83 -0
- package/dist/commands/projects/delete.d.ts +10 -0
- package/dist/commands/projects/delete.js +68 -0
- package/dist/commands/projects/index.d.ts +3 -0
- package/dist/commands/projects/index.js +3 -0
- package/dist/commands/projects/list.d.ts +8 -0
- package/dist/commands/projects/list.js +75 -0
- package/dist/commands/qualityGate.d.ts +14 -6
- package/dist/commands/qualityGate.js +125 -39
- package/dist/commands/results/index.d.ts +2 -0
- package/dist/commands/results/index.js +2 -0
- package/dist/commands/results/pack.d.ts +10 -0
- package/dist/commands/results/pack.js +106 -0
- package/dist/commands/results/unpack.d.ts +9 -0
- package/dist/commands/results/unpack.js +79 -0
- package/dist/commands/run.d.ts +24 -10
- package/dist/commands/run.js +279 -109
- package/dist/commands/slack.d.ts +9 -5
- package/dist/commands/slack.js +55 -31
- package/dist/commands/testplan.d.ts +8 -6
- package/dist/commands/testplan.js +38 -30
- package/dist/commands/watch.d.ts +12 -10
- package/dist/commands/watch.js +110 -106
- package/dist/commands/whoami.d.ts +8 -0
- package/dist/commands/whoami.js +57 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +36 -28
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/logs.d.ts +3 -0
- package/dist/utils/logs.js +32 -0
- package/dist/utils/process.d.ts +8 -2
- package/dist/utils/process.js +17 -6
- package/dist/utils/terminal.d.ts +1 -1
- package/dist/utils/terminal.js +1 -1
- package/package.json +35 -15
- package/dist/utils/commands.d.ts +0 -16
- package/dist/utils/commands.js +0 -14
package/dist/commands/run.js
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
|
-
import { AllureReport, isFileNotFoundError,
|
|
2
|
-
import { createTestPlan } from "@
|
|
3
|
-
import { allureResultsDirectoriesWatcher, delayedFileProcessingWatcher, newFilesInDirectoryWatcher, } from "@
|
|
4
|
-
import
|
|
5
|
-
import { PathResultFile } from "@
|
|
1
|
+
import { AllureReport, QualityGateState, isFileNotFoundError, readConfig, stringifyQualityGateResults, } from "@allurereport/core";
|
|
2
|
+
import { createTestPlan } from "@allurereport/core-api";
|
|
3
|
+
import { allureResultsDirectoriesWatcher, delayedFileProcessingWatcher, newFilesInDirectoryWatcher, } from "@allurereport/directory-watcher";
|
|
4
|
+
import Awesome from "@allurereport/plugin-awesome";
|
|
5
|
+
import { BufferResultFile, PathResultFile } from "@allurereport/reader-api";
|
|
6
|
+
import { KnownError } from "@allurereport/service";
|
|
7
|
+
import { Command, Option } from "clipanion";
|
|
6
8
|
import * as console from "node:console";
|
|
7
9
|
import { mkdtemp, realpath, rm, writeFile } from "node:fs/promises";
|
|
8
10
|
import { tmpdir } from "node:os";
|
|
9
11
|
import { join, resolve } from "node:path";
|
|
10
|
-
import process from "node:process";
|
|
11
|
-
import
|
|
12
|
+
import process, { exit } from "node:process";
|
|
13
|
+
import terminate from "terminate/promise";
|
|
14
|
+
import { red } from "yoctocolors";
|
|
12
15
|
import { logTests, runProcess, terminationOf } from "../utils/index.js";
|
|
13
|
-
|
|
16
|
+
import { logError } from "../utils/logs.js";
|
|
17
|
+
const runTests = async (params) => {
|
|
18
|
+
const { allureReport, knownIssues, cwd, command, commandArgs, logs, environment, withQualityGate, silent } = params;
|
|
14
19
|
let testProcessStarted = false;
|
|
15
20
|
const allureResultsWatchers = new Map();
|
|
16
21
|
const processWatcher = delayedFileProcessingWatcher(async (path) => {
|
|
@@ -44,124 +49,289 @@ const runTests = async (allureReport, cwd, command, commandArgs, environment, si
|
|
|
44
49
|
await allureResultsWatch.initialScan();
|
|
45
50
|
testProcessStarted = true;
|
|
46
51
|
const beforeProcess = Date.now();
|
|
47
|
-
const testProcess = runProcess(
|
|
52
|
+
const testProcess = runProcess({
|
|
53
|
+
command,
|
|
54
|
+
commandArgs,
|
|
55
|
+
cwd,
|
|
56
|
+
environment,
|
|
57
|
+
logs,
|
|
58
|
+
});
|
|
59
|
+
const qualityGateState = new QualityGateState();
|
|
60
|
+
let qualityGateUnsub;
|
|
61
|
+
let qualityGateResults = [];
|
|
62
|
+
let testProcessStdout = "";
|
|
63
|
+
let testProcessStderr = "";
|
|
64
|
+
if (withQualityGate) {
|
|
65
|
+
qualityGateUnsub = allureReport.realtimeSubscriber.onTestResults(async (testResults) => {
|
|
66
|
+
const trs = await Promise.all(testResults.map((tr) => allureReport.store.testResultById(tr)));
|
|
67
|
+
const filteredTrs = trs.filter((tr) => tr !== undefined);
|
|
68
|
+
if (!filteredTrs.length) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const { results, fastFailed } = await allureReport.validate({
|
|
72
|
+
trs: filteredTrs,
|
|
73
|
+
state: qualityGateState,
|
|
74
|
+
knownIssues,
|
|
75
|
+
});
|
|
76
|
+
if (!fastFailed) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
allureReport.realtimeDispatcher.sendQualityGateResults(results);
|
|
80
|
+
qualityGateResults = results;
|
|
81
|
+
try {
|
|
82
|
+
await terminate(testProcess.pid, "SIGTERM");
|
|
83
|
+
}
|
|
84
|
+
catch (err) {
|
|
85
|
+
if (err.message.includes("kill ESRCH")) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
throw err;
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
if (logs === "pipe") {
|
|
93
|
+
testProcess.stdout?.setEncoding("utf8").on?.("data", (data) => {
|
|
94
|
+
testProcessStdout += data;
|
|
95
|
+
if (silent) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
process.stdout.write(data);
|
|
99
|
+
});
|
|
100
|
+
testProcess.stderr?.setEncoding("utf8").on?.("data", async (data) => {
|
|
101
|
+
testProcessStderr += data;
|
|
102
|
+
if (silent) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
process.stderr.write(data);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
48
108
|
const code = await terminationOf(testProcess);
|
|
49
109
|
const afterProcess = Date.now();
|
|
50
|
-
|
|
110
|
+
if (code !== null) {
|
|
111
|
+
console.log(`process finished with code ${code} (${afterProcess - beforeProcess}ms)`);
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
console.log(`process terminated (${afterProcess - beforeProcess}ms)`);
|
|
115
|
+
}
|
|
51
116
|
await allureResultsWatch.abort();
|
|
52
117
|
for (const [ar, watcher] of allureResultsWatchers) {
|
|
53
118
|
await watcher.abort();
|
|
54
119
|
allureResultsWatchers.delete(ar);
|
|
55
120
|
}
|
|
56
121
|
await processWatcher.abort();
|
|
122
|
+
qualityGateUnsub?.();
|
|
123
|
+
return {
|
|
124
|
+
code,
|
|
125
|
+
stdout: testProcessStdout,
|
|
126
|
+
stderr: testProcessStderr,
|
|
127
|
+
qualityGateResults,
|
|
128
|
+
};
|
|
57
129
|
};
|
|
58
|
-
export
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
130
|
+
export class RunCommand extends Command {
|
|
131
|
+
constructor() {
|
|
132
|
+
super(...arguments);
|
|
133
|
+
this.config = Option.String("--config,-c", {
|
|
134
|
+
description: "The path Allure config file",
|
|
135
|
+
});
|
|
136
|
+
this.cwd = Option.String("--cwd", {
|
|
137
|
+
description: "The working directory for the command to run (default: current working directory)",
|
|
138
|
+
});
|
|
139
|
+
this.output = Option.String("--output,-o", {
|
|
140
|
+
description: "The output file name, allure.csv by default. Accepts absolute paths (default: ./allure-report)",
|
|
141
|
+
});
|
|
142
|
+
this.reportName = Option.String("--report-name,--name", {
|
|
143
|
+
description: "The report name (default: Allure Report)",
|
|
144
|
+
});
|
|
145
|
+
this.rerun = Option.String("--rerun", {
|
|
146
|
+
description: "The number of reruns for failed tests (default: 0)",
|
|
147
|
+
});
|
|
148
|
+
this.silent = Option.Boolean("--silent", {
|
|
149
|
+
description: "Don't pipe the process output logs to console (default: 0)",
|
|
150
|
+
});
|
|
151
|
+
this.ignoreLogs = Option.Boolean("--ignore-logs", {
|
|
152
|
+
description: "Prevent logs attaching to the report (default: false)",
|
|
153
|
+
});
|
|
154
|
+
this.stage = Option.String("--stage", {
|
|
155
|
+
description: "Runs tests in stage mode to collect results to a stage archive with the provided name (default: empty string)",
|
|
156
|
+
});
|
|
157
|
+
this.environment = Option.String("--environment", {
|
|
158
|
+
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)",
|
|
159
|
+
});
|
|
160
|
+
this.commandToRun = Option.Rest();
|
|
76
161
|
}
|
|
77
|
-
|
|
78
|
-
if (
|
|
79
|
-
|
|
162
|
+
get logs() {
|
|
163
|
+
if (this.silent) {
|
|
164
|
+
return this.ignoreLogs ? "ignore" : "pipe";
|
|
80
165
|
}
|
|
166
|
+
return this.ignoreLogs ? "inherit" : "pipe";
|
|
81
167
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
168
|
+
async execute() {
|
|
169
|
+
const args = this.commandToRun.filter((arg) => arg !== "--");
|
|
170
|
+
if (!args || !args.length) {
|
|
171
|
+
throw new Error("expecting command to be specified after --, e.g. allure run -- npm run test");
|
|
172
|
+
}
|
|
173
|
+
const before = new Date().getTime();
|
|
174
|
+
process.on("exit", (exitCode) => {
|
|
175
|
+
const after = new Date().getTime();
|
|
176
|
+
console.log(`exit code ${exitCode} (${after - before}ms)`);
|
|
177
|
+
});
|
|
178
|
+
const command = args[0];
|
|
179
|
+
const commandArgs = args.slice(1);
|
|
180
|
+
const cwd = await realpath(this.cwd ?? process.cwd());
|
|
181
|
+
console.log(`${command} ${commandArgs.join(" ")}`);
|
|
182
|
+
const maxRerun = this.rerun ? parseInt(this.rerun, 10) : 0;
|
|
183
|
+
const config = await readConfig(cwd, this.config, { output: this.output, name: this.reportName });
|
|
184
|
+
const withQualityGate = !!config.qualityGate;
|
|
185
|
+
const withRerun = !!this.rerun;
|
|
186
|
+
if (withQualityGate && withRerun) {
|
|
187
|
+
console.error(red("At this moment, quality gate and rerun can't be used at the same time!"));
|
|
188
|
+
console.error(red("Consider using --rerun=0 or disable quality gate in the config to run tests"));
|
|
189
|
+
exit(-1);
|
|
190
|
+
}
|
|
191
|
+
try {
|
|
192
|
+
await rm(config.output, { recursive: true });
|
|
193
|
+
}
|
|
194
|
+
catch (e) {
|
|
195
|
+
if (!isFileNotFoundError(e)) {
|
|
196
|
+
console.error("could not clean output directory", e);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
const allureReport = new AllureReport({
|
|
200
|
+
...config,
|
|
201
|
+
environment: this.environment,
|
|
202
|
+
stage: this.stage,
|
|
203
|
+
realTime: false,
|
|
204
|
+
plugins: [
|
|
205
|
+
...(config.plugins?.length
|
|
206
|
+
? config.plugins
|
|
207
|
+
: [
|
|
208
|
+
{
|
|
209
|
+
id: "awesome",
|
|
210
|
+
enabled: true,
|
|
211
|
+
options: {},
|
|
212
|
+
plugin: new Awesome({
|
|
213
|
+
reportName: config.name,
|
|
214
|
+
}),
|
|
215
|
+
},
|
|
216
|
+
]),
|
|
217
|
+
],
|
|
218
|
+
});
|
|
219
|
+
const knownIssues = await allureReport.store.allKnownIssues();
|
|
220
|
+
await allureReport.start();
|
|
221
|
+
const globalExitCode = {
|
|
222
|
+
original: 0,
|
|
223
|
+
actual: undefined,
|
|
224
|
+
};
|
|
225
|
+
let qualityGateResults;
|
|
226
|
+
let testProcessResult = null;
|
|
227
|
+
try {
|
|
228
|
+
testProcessResult = await runTests({
|
|
229
|
+
logs: this.logs,
|
|
230
|
+
silent: this.silent,
|
|
231
|
+
allureReport,
|
|
232
|
+
knownIssues,
|
|
233
|
+
cwd,
|
|
234
|
+
command,
|
|
235
|
+
commandArgs,
|
|
236
|
+
environment: {},
|
|
237
|
+
withQualityGate,
|
|
238
|
+
});
|
|
239
|
+
for (let rerun = 0; rerun < maxRerun; rerun++) {
|
|
240
|
+
const failed = await allureReport.store.failedTestResults();
|
|
241
|
+
if (failed.length === 0) {
|
|
242
|
+
console.log("no failed tests is detected.");
|
|
243
|
+
break;
|
|
244
|
+
}
|
|
245
|
+
const testPlan = createTestPlan(failed);
|
|
246
|
+
console.log(`rerun number ${rerun} of ${testPlan.tests.length} tests:`);
|
|
247
|
+
logTests(failed);
|
|
248
|
+
const tmpDir = await mkdtemp(join(tmpdir(), "allure-run-"));
|
|
249
|
+
const testPlanPath = resolve(tmpDir, `${rerun}-testplan.json`);
|
|
250
|
+
await writeFile(testPlanPath, JSON.stringify(testPlan));
|
|
251
|
+
testProcessResult = await runTests({
|
|
252
|
+
silent: this.silent,
|
|
253
|
+
logs: this.logs,
|
|
254
|
+
allureReport,
|
|
255
|
+
knownIssues,
|
|
256
|
+
cwd,
|
|
257
|
+
command,
|
|
258
|
+
commandArgs,
|
|
259
|
+
environment: {
|
|
260
|
+
ALLURE_TESTPLAN_PATH: testPlanPath,
|
|
261
|
+
ALLURE_RERUN: `${rerun}`,
|
|
96
262
|
},
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
263
|
+
withQualityGate,
|
|
264
|
+
});
|
|
265
|
+
await rm(tmpDir, { recursive: true });
|
|
266
|
+
logTests(await allureReport.store.allTestResults());
|
|
267
|
+
}
|
|
268
|
+
const trs = await allureReport.store.allTestResults({ includeHidden: false });
|
|
269
|
+
qualityGateResults = testProcessResult?.qualityGateResults ?? [];
|
|
270
|
+
if (withQualityGate && !qualityGateResults?.length) {
|
|
271
|
+
const { results } = await allureReport.validate({
|
|
272
|
+
trs,
|
|
273
|
+
knownIssues,
|
|
274
|
+
});
|
|
275
|
+
qualityGateResults = results;
|
|
276
|
+
}
|
|
277
|
+
if (qualityGateResults?.length) {
|
|
278
|
+
const qualityGateMessage = stringifyQualityGateResults(qualityGateResults);
|
|
279
|
+
console.error(qualityGateMessage);
|
|
280
|
+
allureReport.realtimeDispatcher.sendQualityGateResults(qualityGateResults);
|
|
281
|
+
}
|
|
282
|
+
globalExitCode.original = testProcessResult?.code ?? -1;
|
|
283
|
+
if (withQualityGate) {
|
|
284
|
+
globalExitCode.actual = qualityGateResults.length > 0 ? 1 : 0;
|
|
285
|
+
}
|
|
107
286
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
287
|
+
catch (error) {
|
|
288
|
+
globalExitCode.actual = 1;
|
|
289
|
+
if (error instanceof KnownError) {
|
|
290
|
+
console.error(red(error.message));
|
|
291
|
+
allureReport.realtimeDispatcher.sendGlobalError({
|
|
292
|
+
message: error.message,
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
else {
|
|
296
|
+
await logError("Failed to run tests using Allure due to unexpected error", error);
|
|
297
|
+
allureReport.realtimeDispatcher.sendGlobalError({
|
|
298
|
+
message: error.message,
|
|
299
|
+
trace: error.stack,
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
const processFailed = Math.abs(globalExitCode.actual ?? globalExitCode.original) !== 0;
|
|
304
|
+
if (!this.ignoreLogs && testProcessResult?.stdout) {
|
|
305
|
+
const stdoutResultFile = new BufferResultFile(Buffer.from(testProcessResult.stdout, "utf8"), "stdout.txt");
|
|
306
|
+
stdoutResultFile.contentType = "text/plain";
|
|
307
|
+
allureReport.realtimeDispatcher.sendGlobalAttachment(stdoutResultFile);
|
|
308
|
+
}
|
|
309
|
+
if (!this.ignoreLogs && testProcessResult?.stderr) {
|
|
310
|
+
const stderrResultFile = new BufferResultFile(Buffer.from(testProcessResult.stderr, "utf8"), "stderr.txt");
|
|
311
|
+
stderrResultFile.contentType = "text/plain";
|
|
312
|
+
allureReport.realtimeDispatcher.sendGlobalAttachment(stderrResultFile);
|
|
313
|
+
if (processFailed) {
|
|
314
|
+
allureReport.realtimeDispatcher.sendGlobalError({
|
|
315
|
+
message: "Test process has failed",
|
|
316
|
+
trace: testProcessResult.stderr,
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
allureReport.realtimeDispatcher.sendGlobalExitCode(globalExitCode);
|
|
321
|
+
await allureReport.done();
|
|
322
|
+
exit(globalExitCode.actual ?? globalExitCode.original);
|
|
120
323
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
};
|
|
125
|
-
export const RunCommand = createCommand({
|
|
126
|
-
name: "run",
|
|
324
|
+
}
|
|
325
|
+
RunCommand.paths = [["run"]];
|
|
326
|
+
RunCommand.usage = Command.Usage({
|
|
127
327
|
description: "Run specified command",
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
description: "The path Allure config file",
|
|
133
|
-
},
|
|
134
|
-
],
|
|
135
|
-
[
|
|
136
|
-
"--cwd <cwd>",
|
|
137
|
-
{
|
|
138
|
-
description: "The working directory for the command to run (Default: current working directory)",
|
|
139
|
-
},
|
|
140
|
-
],
|
|
141
|
-
[
|
|
142
|
-
"--output, -o <file>",
|
|
143
|
-
{
|
|
144
|
-
description: "The output file name, allure.csv by default. Accepts absolute paths (Default: ./allure-report)",
|
|
145
|
-
},
|
|
146
|
-
],
|
|
147
|
-
[
|
|
148
|
-
"--report-name, --name <string>",
|
|
149
|
-
{
|
|
150
|
-
description: "The report name (Default: Allure Report)",
|
|
151
|
-
},
|
|
152
|
-
],
|
|
153
|
-
[
|
|
154
|
-
"--rerun <number>",
|
|
155
|
-
{
|
|
156
|
-
description: "The number of reruns for failed tests (Default: 0)",
|
|
157
|
-
},
|
|
158
|
-
],
|
|
328
|
+
details: "This command runs the specified command and collects Allure results.",
|
|
329
|
+
examples: [
|
|
330
|
+
["run -- npm run test", "Run npm run test and collect Allure results"],
|
|
331
|
+
["run --rerun 3 -- npm run test", "Run npm run test and rerun failed tests up to 3 times"],
|
|
159
332
|
[
|
|
160
|
-
"--
|
|
161
|
-
|
|
162
|
-
description: "Don't pipe the process output logs to console (Default: 0)",
|
|
163
|
-
},
|
|
333
|
+
"run --stage=my-stage -- npm run test",
|
|
334
|
+
"Run npm run test and pack inner report state into my-stage.zip archive to restore the state in the next run",
|
|
164
335
|
],
|
|
165
336
|
],
|
|
166
|
-
action: RunCommandAction,
|
|
167
337
|
});
|
package/dist/commands/slack.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import { Command } from "clipanion";
|
|
2
|
+
export declare class SlackCommand extends Command {
|
|
3
|
+
static paths: string[][];
|
|
4
|
+
static usage: import("clipanion").Usage;
|
|
5
|
+
resultsDir: string;
|
|
6
|
+
config: string | undefined;
|
|
7
|
+
cwd: string | undefined;
|
|
2
8
|
token: string;
|
|
3
9
|
channel: string;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export declare const SlackCommand: (cli: import("cac").CAC) => void;
|
|
7
|
-
export {};
|
|
10
|
+
execute(): Promise<void>;
|
|
11
|
+
}
|
package/dist/commands/slack.js
CHANGED
|
@@ -1,37 +1,61 @@
|
|
|
1
|
-
import { AllureReport,
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
1
|
+
import { AllureReport, readConfig } from "@allurereport/core";
|
|
2
|
+
import SlackPlugin from "@allurereport/plugin-slack";
|
|
3
|
+
import { Command, Option } from "clipanion";
|
|
4
|
+
import * as console from "node:console";
|
|
5
|
+
import { realpath } from "node:fs/promises";
|
|
6
|
+
import process from "node:process";
|
|
7
|
+
export class SlackCommand extends Command {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
this.resultsDir = Option.String({ required: true, name: "The directory with Allure results" });
|
|
11
|
+
this.config = Option.String("--config,-c", {
|
|
12
|
+
description: "The path Allure config file",
|
|
13
|
+
});
|
|
14
|
+
this.cwd = Option.String("--cwd", {
|
|
15
|
+
description: "The working directory for the command to run (default: current working directory)",
|
|
16
|
+
});
|
|
17
|
+
this.token = Option.String("--token,-t", {
|
|
18
|
+
description: "Slack Bot User OAuth Token",
|
|
19
|
+
required: true,
|
|
20
|
+
});
|
|
21
|
+
this.channel = Option.String("--channel", {
|
|
22
|
+
description: "Slack channelId",
|
|
23
|
+
required: true,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
async execute() {
|
|
27
|
+
const cwd = await realpath(this.cwd ?? process.cwd());
|
|
28
|
+
const before = new Date().getTime();
|
|
29
|
+
const defaultSlackOptions = {
|
|
30
|
+
token: this.token,
|
|
31
|
+
channel: this.channel,
|
|
32
|
+
};
|
|
33
|
+
const config = await readConfig(cwd, this.config);
|
|
34
|
+
config.plugins = [
|
|
25
35
|
{
|
|
26
|
-
|
|
36
|
+
id: "slack",
|
|
37
|
+
enabled: true,
|
|
38
|
+
options: defaultSlackOptions,
|
|
39
|
+
plugin: new SlackPlugin(defaultSlackOptions),
|
|
27
40
|
},
|
|
28
|
-
]
|
|
41
|
+
];
|
|
42
|
+
const allureReport = new AllureReport(config);
|
|
43
|
+
await allureReport.start();
|
|
44
|
+
await allureReport.readDirectory(this.resultsDir);
|
|
45
|
+
await allureReport.done();
|
|
46
|
+
const after = new Date().getTime();
|
|
47
|
+
console.log(`the report successfully generated (${after - before}ms)`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
SlackCommand.paths = [["slack"]];
|
|
51
|
+
SlackCommand.usage = Command.Usage({
|
|
52
|
+
category: "Reports",
|
|
53
|
+
description: "Posts test results into Slack Channel",
|
|
54
|
+
details: "This command posts test results from the provided Allure Results directory to a Slack channel.",
|
|
55
|
+
examples: [
|
|
29
56
|
[
|
|
30
|
-
"--
|
|
31
|
-
|
|
32
|
-
description: "Slack channelId",
|
|
33
|
-
},
|
|
57
|
+
"slack ./allure-results --token xoxb-token --channel C12345",
|
|
58
|
+
"Post test results from the ./allure-results directory to the specified Slack channel",
|
|
34
59
|
],
|
|
35
60
|
],
|
|
36
|
-
action: SlackCommandAction,
|
|
37
61
|
});
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { Command } from "clipanion";
|
|
2
|
+
export declare class TestPlanCommand extends Command {
|
|
3
|
+
static paths: string[][];
|
|
4
|
+
static usage: import("clipanion").Usage;
|
|
5
|
+
resultsDir: string;
|
|
6
|
+
output: string | undefined;
|
|
7
|
+
execute(): Promise<void>;
|
|
8
|
+
}
|
|
@@ -1,37 +1,45 @@
|
|
|
1
|
-
import { AllureReport, resolveConfig } from "@
|
|
1
|
+
import { AllureReport, resolveConfig } from "@allurereport/core";
|
|
2
|
+
import { Command, Option } from "clipanion";
|
|
3
|
+
import * as console from "node:console";
|
|
2
4
|
import { basename, dirname, resolve } from "node:path";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
export class TestPlanCommand extends Command {
|
|
6
|
+
constructor() {
|
|
7
|
+
super(...arguments);
|
|
8
|
+
this.resultsDir = Option.String({ required: true, name: "The directory with Allure results" });
|
|
9
|
+
this.output = Option.String("--output,-o", {
|
|
10
|
+
description: "The output file name. Absolute paths are accepted as well",
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
async execute() {
|
|
14
|
+
const before = new Date().getTime();
|
|
15
|
+
const resolved = resolve(this.output ?? "./testplan.json");
|
|
16
|
+
const output = dirname(resolved);
|
|
17
|
+
const fileName = basename(resolved);
|
|
18
|
+
const config = await resolveConfig({
|
|
19
|
+
output: output,
|
|
20
|
+
plugins: {
|
|
21
|
+
"@allurereport/plugin-testplan": {
|
|
22
|
+
options: { fileName },
|
|
23
|
+
},
|
|
14
24
|
},
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
});
|
|
26
|
+
const allureReport = new AllureReport(config);
|
|
27
|
+
await allureReport.start();
|
|
28
|
+
await allureReport.readDirectory(this.resultsDir);
|
|
29
|
+
await allureReport.done();
|
|
30
|
+
const after = new Date().getTime();
|
|
31
|
+
console.log(`the report successfully generated (${after - before}ms)`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
TestPlanCommand.paths = [["testplan"]];
|
|
35
|
+
TestPlanCommand.usage = Command.Usage({
|
|
26
36
|
description: "Generates testplan.json based on provided Allure Results",
|
|
27
|
-
|
|
37
|
+
details: "This command generates a testplan.json file from the provided Allure Results directory.",
|
|
38
|
+
examples: [
|
|
39
|
+
["testplan ./allure-results", "Generate a testplan.json file from the ./allure-results directory"],
|
|
28
40
|
[
|
|
29
|
-
"--output
|
|
30
|
-
|
|
31
|
-
description: "The output file name. Absolute paths are accepted as well",
|
|
32
|
-
default: "testplan.json",
|
|
33
|
-
},
|
|
41
|
+
"testplan ./allure-results --output custom-testplan.json",
|
|
42
|
+
"Generate a custom-testplan.json file from the ./allure-results directory",
|
|
34
43
|
],
|
|
35
44
|
],
|
|
36
|
-
action: TestPlanCommandAction,
|
|
37
45
|
});
|
package/dist/commands/watch.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { Command } from "clipanion";
|
|
2
|
+
export declare class WatchCommand extends Command {
|
|
3
|
+
static paths: string[][];
|
|
4
|
+
static usage: import("clipanion").Usage;
|
|
5
|
+
resultsDir: string;
|
|
6
|
+
config: string | undefined;
|
|
7
|
+
cwd: string | undefined;
|
|
8
|
+
output: string | undefined;
|
|
9
|
+
reportName: string | undefined;
|
|
10
|
+
port: string | undefined;
|
|
11
|
+
execute(): Promise<void>;
|
|
12
|
+
}
|