UNPKG

1.76 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.InMemoryAllureWriter = void 0;
4const fs_1 = require("fs");
5class InMemoryAllureWriter {
6 constructor() {
7 this.groups = [];
8 this.tests = [];
9 this.attachments = {};
10 }
11 writeGroup(result) {
12 this.groups.push(result);
13 }
14 writeResult(result) {
15 this.tests.push(result);
16 }
17 writeAttachment(name, content) {
18 this.attachments[name] = content;
19 }
20 writeAttachmentFromPath(from, toFileName) {
21 this.attachments[toFileName] = (0, fs_1.readFileSync)(from);
22 }
23 writeCategoriesDefinitions(categories) {
24 if (this.categories) {
25 console.warn("overwriting existing categories");
26 }
27 this.categories = categories;
28 }
29 writeEnvironmentInfo(envInfo) {
30 if (this.envInfo) {
31 console.warn("overwriting existing environment info");
32 }
33 this.envInfo = envInfo;
34 }
35 reset() {
36 this.groups = [];
37 this.tests = [];
38 this.attachments = {};
39 }
40 getMaybeTestByName(name) {
41 return this.tests.find((t) => t.name === name);
42 }
43 getTestByName(name) {
44 const res = this.getMaybeTestByName(name);
45 if (!res) {
46 throw new Error(`Test not found: ${name}`);
47 }
48 return res;
49 }
50 getMaybeGroupByName(name) {
51 return this.groups.find((g) => g.name === name);
52 }
53 getGroupByName(name) {
54 const res = this.getMaybeGroupByName(name);
55 if (!res) {
56 throw new Error(`Group not found: ${name}`);
57 }
58 return res;
59 }
60}
61exports.InMemoryAllureWriter = InMemoryAllureWriter;
62//# sourceMappingURL=InMemoryAllureWriter.js.map
\No newline at end of file