UNPKG

1.84 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.AllureRuntime = void 0;
4const uuid_1 = require("uuid");
5const AllureGroup_1 = require("./AllureGroup");
6const writers_1 = require("./writers");
7class AllureRuntime {
8 constructor(config) {
9 this.config = config;
10 this.writer = config.writer || new writers_1.AllureWriter(config);
11 }
12 startGroup(name) {
13 const allureContainer = new AllureGroup_1.AllureGroup(this);
14 allureContainer.name = name || "Unnamed";
15 return allureContainer;
16 }
17 writeResult(result) {
18 const modifiedResult = this.config.testMapper !== undefined ? this.config.testMapper(result) : result;
19 if (modifiedResult != null) {
20 this.writer.writeResult(modifiedResult);
21 }
22 }
23 writeGroup(result) {
24 this.writer.writeGroup(result);
25 }
26 writeAttachment(content, options) {
27 if (typeof options === "string") {
28 options = { contentType: options };
29 }
30 const extension = writers_1.typeToExtension(options);
31 const fileName = `${uuid_1.v4()}-attachment.${extension}`;
32 this.writer.writeAttachment(fileName, content);
33 return fileName;
34 }
35 writeEnvironmentInfo(info) {
36 this.writer.writeEnvironmentInfo(info || process.env);
37 }
38 writeCategoriesDefinitions(categories) {
39 const serializedCategories = categories.map(c => {
40 if (c.messageRegex instanceof RegExp)
41 c.messageRegex = c.messageRegex.source;
42 if (c.traceRegex instanceof RegExp)
43 c.traceRegex = c.traceRegex.source;
44 return c;
45 });
46 this.writer.writeCategoriesDefinitions(serializedCategories);
47 }
48}
49exports.AllureRuntime = AllureRuntime;
50//# sourceMappingURL=AllureRuntime.js.map
\No newline at end of file