@orangebeard-io/playwright-orangebeard-reporter 1.0.2 → 1.0.3

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.
@@ -0,0 +1,283 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
+ return new (P || (P = Promise))(function (resolve, reject) {
38
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
39
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
40
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
41
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
42
+ });
43
+ };
44
+ var __importDefault = (this && this.__importDefault) || function (mod) {
45
+ return (mod && mod.__esModule) ? mod : { "default": mod };
46
+ };
47
+ Object.defineProperty(exports, "__esModule", { value: true });
48
+ exports.OrangebeardReporter = void 0;
49
+ const utils_1 = require("./utils");
50
+ const OrangebeardAsyncV3Client_1 = __importDefault(require("@orangebeard-io/javascript-client/dist/client/OrangebeardAsyncV3Client"));
51
+ const StartTest_1 = require("@orangebeard-io/javascript-client/dist/client/models/StartTest");
52
+ const Log_1 = require("@orangebeard-io/javascript-client/dist/client/models/Log");
53
+ const FinishStep_1 = require("@orangebeard-io/javascript-client/dist/client/models/FinishStep");
54
+ var TestType = StartTest_1.StartTest.TestType;
55
+ var LogFormat = Log_1.Log.LogFormat;
56
+ var LogLevel = Log_1.Log.LogLevel;
57
+ var Status = FinishStep_1.FinishStep.Status;
58
+ const path = __importStar(require("node:path"));
59
+ class OrangebeardReporter {
60
+ constructor() {
61
+ this.suites = new Map(); //suiteNames , uuid
62
+ this.tests = new Map(); //testId, uuid
63
+ this.steps = new Map(); //testId_stepPath, uuid
64
+ this.promises = [];
65
+ this.client = new OrangebeardAsyncV3Client_1.default();
66
+ this.config = this.client.config;
67
+ }
68
+ onBegin() {
69
+ this.testRunId = this.client.startTestRun({
70
+ testSetName: this.config.testset,
71
+ description: this.config.description,
72
+ startTime: (0, utils_1.getTime)(),
73
+ attributes: this.config.attributes
74
+ });
75
+ }
76
+ onEnd() {
77
+ return __awaiter(this, void 0, void 0, function* () {
78
+ yield Promise.all(this.promises);
79
+ return this.client.finishTestRun(this.testRunId, { endTime: (0, utils_1.getTime)() });
80
+ });
81
+ }
82
+ onStdErr(chunk, test, _result) {
83
+ //log error level
84
+ if (typeof test === 'object' && test !== null) {
85
+ const testUUID = this.tests.get(test.id);
86
+ const message = chunk.toString();
87
+ this.client.log({
88
+ logFormat: LogFormat.PLAIN_TEXT,
89
+ logLevel: LogLevel.ERROR,
90
+ logTime: (0, utils_1.getTime)(),
91
+ message: message,
92
+ testRunUUID: this.testRunId,
93
+ testUUID: testUUID
94
+ });
95
+ }
96
+ }
97
+ onStdOut(chunk, test, _result) {
98
+ if (typeof test === 'object' && test !== null) {
99
+ const testUUID = this.tests.get(test.id);
100
+ const message = chunk.toString();
101
+ this.client.log({
102
+ logFormat: LogFormat.PLAIN_TEXT,
103
+ logLevel: LogLevel.INFO,
104
+ logTime: (0, utils_1.getTime)(),
105
+ message: message,
106
+ testRunUUID: this.testRunId,
107
+ testUUID: testUUID
108
+ });
109
+ }
110
+ }
111
+ onStepBegin(test, _result, step) {
112
+ //start step
113
+ const testUUID = this.tests.get(test.id);
114
+ const stepUUID = this.client.startStep({
115
+ startTime: (0, utils_1.getTime)(),
116
+ stepName: step.title || step.titlePath().toString() || 'Untitled step',
117
+ description: step.location ? `${path.basename(step.location.file)}:${step.location.line}` : undefined,
118
+ testRunUUID: this.testRunId,
119
+ testUUID: testUUID,
120
+ parentStepUUID: step.parent ? this.steps.get(test.id + "|" + step.parent.titlePath()) : undefined,
121
+ });
122
+ this.steps.set(test.id + "|" + step.titlePath(), stepUUID);
123
+ if (step.location) {
124
+ this.client.log({
125
+ logFormat: LogFormat.MARKDOWN,
126
+ logLevel: LogLevel.INFO,
127
+ logTime: (0, utils_1.getTime)(),
128
+ message: (0, utils_1.getCodeSnippet)(step.location.file, step.location.line),
129
+ testRunUUID: this.testRunId,
130
+ testUUID: testUUID,
131
+ stepUUID: stepUUID
132
+ });
133
+ }
134
+ }
135
+ onStepEnd(test, _result, step) {
136
+ const testUUID = this.tests.get(test.id);
137
+ const stepUUID = this.steps.get(test.id + "|" + step.titlePath());
138
+ if (step.error) {
139
+ const message = step.error.message;
140
+ this.client.log({
141
+ logFormat: LogFormat.MARKDOWN,
142
+ logLevel: LogLevel.ERROR,
143
+ logTime: (0, utils_1.getTime)(),
144
+ message: (0, utils_1.ansiToMarkdown)(message),
145
+ testRunUUID: this.testRunId,
146
+ testUUID: testUUID,
147
+ stepUUID: stepUUID
148
+ });
149
+ if (step.error.snippet) {
150
+ this.client.log({
151
+ logFormat: LogFormat.MARKDOWN,
152
+ logLevel: LogLevel.ERROR,
153
+ logTime: (0, utils_1.getTime)(),
154
+ message: `\`\`\`js\n${(0, utils_1.removeAnsi)(step.error.snippet)}\n\`\`\``,
155
+ testRunUUID: this.testRunId,
156
+ testUUID: testUUID,
157
+ stepUUID: stepUUID
158
+ });
159
+ }
160
+ }
161
+ this.client.finishStep(this.steps.get(test.id + "|" + step.titlePath()), {
162
+ endTime: (0, utils_1.getTime)(),
163
+ status: step.error ? Status.FAILED : Status.PASSED,
164
+ testRunUUID: this.testRunId
165
+ });
166
+ this.steps.delete(test.id + "|" + step.titlePath());
167
+ }
168
+ onTestBegin(test) {
169
+ //check suite
170
+ const suiteUUID = this.getOrStartSuite(test.parent.titlePath());
171
+ const attributes = [];
172
+ for (const tag of test.tags) {
173
+ attributes.push({ value: tag });
174
+ }
175
+ const testUUID = this.client.startTest({
176
+ testType: TestType.TEST,
177
+ testRunUUID: this.testRunId,
178
+ suiteUUID: suiteUUID,
179
+ testName: test.title,
180
+ startTime: (0, utils_1.getTime)(),
181
+ description: this.getTestDescription(test),
182
+ attributes: attributes
183
+ });
184
+ this.tests.set(test.id, testUUID);
185
+ }
186
+ onTestEnd(test, result) {
187
+ return __awaiter(this, void 0, void 0, function* () {
188
+ const testUUID = this.tests.get(test.id);
189
+ if (result.attachments.length > 0) {
190
+ let message = "";
191
+ for (const attachment of result.attachments) {
192
+ message += `- ${attachment.name} (${attachment.contentType})\n`;
193
+ }
194
+ const attachmentsLogUUID = this.client.log({
195
+ logFormat: LogFormat.MARKDOWN,
196
+ logLevel: LogLevel.INFO,
197
+ logTime: (0, utils_1.getTime)(),
198
+ message: message,
199
+ testRunUUID: this.testRunId,
200
+ testUUID: testUUID
201
+ });
202
+ for (const attachment of result.attachments) {
203
+ this.promises.push(this.logAttachment(attachment, testUUID, attachmentsLogUUID));
204
+ }
205
+ }
206
+ //determine status
207
+ const status = utils_1.testStatusMap[result.status];
208
+ //finish test
209
+ this.client.finishTest(testUUID, {
210
+ testRunUUID: this.testRunId,
211
+ status: status,
212
+ endTime: (0, utils_1.getTime)()
213
+ });
214
+ this.tests.delete(test.id);
215
+ });
216
+ }
217
+ printsToStdio() {
218
+ return false;
219
+ }
220
+ getOrStartSuite(suitePath) {
221
+ const filteredSuitePath = suitePath.filter(name => name !== "");
222
+ let currentPath = [];
223
+ let parentSuiteUUID = undefined;
224
+ for (const suiteName of filteredSuitePath) {
225
+ currentPath.push(suiteName);
226
+ const existingSuiteUUID = this.suites.get(currentPath.join('|'));
227
+ if (existingSuiteUUID) {
228
+ parentSuiteUUID = existingSuiteUUID;
229
+ }
230
+ else {
231
+ const newSuitesUUIDs = this.client.startSuite({
232
+ testRunUUID: this.testRunId,
233
+ parentSuiteUUID: parentSuiteUUID,
234
+ suiteNames: [suiteName],
235
+ });
236
+ if (newSuitesUUIDs && newSuitesUUIDs.length > 0) {
237
+ parentSuiteUUID = newSuitesUUIDs[0];
238
+ this.suites.set(currentPath.join('|'), parentSuiteUUID);
239
+ }
240
+ else {
241
+ console.error(`Failed to create suite for path: ${currentPath.join(' > ')}`);
242
+ }
243
+ }
244
+ }
245
+ return parentSuiteUUID;
246
+ }
247
+ getTestDescription(test) {
248
+ let description = `${path.basename(test.location.file)}:${test.location.line}\n`;
249
+ for (const annotation of test.annotations) {
250
+ description = `${description + annotation.type}: ${annotation.description}\n`;
251
+ }
252
+ return description;
253
+ }
254
+ logAttachment(attachment, testUUID, logUUID) {
255
+ return __awaiter(this, void 0, void 0, function* () {
256
+ let content;
257
+ if (attachment.body) {
258
+ content = attachment.body;
259
+ }
260
+ else if (attachment.path) {
261
+ content = yield (0, utils_1.getBytes)(attachment.path);
262
+ }
263
+ else {
264
+ throw new Error("Attachment must have either body or path defined.");
265
+ }
266
+ const orangebeardAttachment = {
267
+ file: {
268
+ name: path.basename(attachment.path),
269
+ content: content,
270
+ contentType: attachment.contentType,
271
+ },
272
+ metaData: {
273
+ testRunUUID: this.testRunId,
274
+ testUUID: testUUID,
275
+ logUUID: logUUID,
276
+ attachmentTime: (0, utils_1.getTime)()
277
+ },
278
+ };
279
+ this.client.sendAttachment(orangebeardAttachment);
280
+ });
281
+ }
282
+ }
283
+ exports.OrangebeardReporter = OrangebeardReporter;
@@ -0,0 +1,177 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
+ return new (P || (P = Promise))(function (resolve, reject) {
38
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
39
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
40
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
41
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
42
+ });
43
+ };
44
+ Object.defineProperty(exports, "__esModule", { value: true });
45
+ exports.getBytes = exports.testStatusMap = void 0;
46
+ exports.getTime = getTime;
47
+ exports.removeAnsi = removeAnsi;
48
+ exports.ansiToMarkdown = ansiToMarkdown;
49
+ exports.getCodeSnippet = getCodeSnippet;
50
+ const core_1 = require("@js-joda/core");
51
+ const FinishTest_1 = require("@orangebeard-io/javascript-client/dist/client/models/FinishTest");
52
+ const fs = __importStar(require("node:fs"));
53
+ const util_1 = require("util");
54
+ var Status = FinishTest_1.FinishTest.Status;
55
+ const stat = (0, util_1.promisify)(fs.stat);
56
+ const access = (0, util_1.promisify)(fs.access);
57
+ function getTime() {
58
+ return core_1.ZonedDateTime.now().withFixedOffsetZone().toString();
59
+ }
60
+ exports.testStatusMap = {
61
+ "passed": Status.PASSED,
62
+ "failed": Status.FAILED,
63
+ "timedOut": Status.TIMED_OUT,
64
+ "skipped": Status.SKIPPED,
65
+ "interrupted": Status.STOPPED
66
+ };
67
+ function removeAnsi(ansiString) {
68
+ const parts = ansiString.split(/(\u001b\[[0-9;]*[mG])/);
69
+ let result = "";
70
+ for (const part of parts) {
71
+ if (!part.startsWith("\u001b[")) {
72
+ result += part;
73
+ }
74
+ }
75
+ return result;
76
+ }
77
+ function ansiToMarkdown(ansiString) {
78
+ let markdown = "";
79
+ let currentStyle = {};
80
+ const ansiCodes = {
81
+ "31": { italic: true },
82
+ "32": { italic: true },
83
+ "39": { italic: false }, // Reset styles
84
+ "2": { code: true },
85
+ "22": { code: false },
86
+ };
87
+ const parts = ansiString.split(/(\u001b\[[0-9;]*[mG])/);
88
+ for (const part of parts) {
89
+ if (part.startsWith("\u001b[")) {
90
+ const code = part.slice(2, -1);
91
+ const codes = code.split(';');
92
+ for (const c of codes) {
93
+ const style = ansiCodes[c]; // Type guard
94
+ if (style) {
95
+ currentStyle = Object.assign(Object.assign({}, currentStyle), style);
96
+ }
97
+ }
98
+ }
99
+ else {
100
+ let formattedPart = part.replace(/\n/g, " \n");
101
+ if (currentStyle.italic) {
102
+ formattedPart = formattedPart.endsWith(" ") ? `*${formattedPart.trim()}* ` : `*${formattedPart}*`;
103
+ }
104
+ if (currentStyle.code) {
105
+ formattedPart = `${formattedPart}`;
106
+ }
107
+ markdown += formattedPart;
108
+ }
109
+ }
110
+ return markdown;
111
+ }
112
+ /**
113
+ * Reads a 3-line snippet from a file, centered around the specified line number.
114
+ *
115
+ * @param filePath - The path to the file.
116
+ * @param lineNumber - The line number to center the snippet around (1-based index).
117
+ * @returns A promise that resolves with the 3-line snippet or an error message if the line is out of range.
118
+ */
119
+ function getCodeSnippet(filePath, lineNumber) {
120
+ if (lineNumber < 1) {
121
+ throw new Error('Line number must be 1 or greater.');
122
+ }
123
+ const fileContent = fs.readFileSync(filePath, 'utf8');
124
+ const lines = fileContent.split(/\r?\n/); // Support both Unix and Windows line endings
125
+ const startLine = Math.max(0, lineNumber - 2); // Zero-based index for one line before
126
+ const endLine = Math.min(lines.length, lineNumber + 1); // One line after
127
+ if (startLine >= lines.length) {
128
+ throw new Error('Line number is out of range.');
129
+ }
130
+ let snippet = lines.slice(startLine, endLine);
131
+ if (snippet.length > 0 && snippet[0].trim() === "") {
132
+ snippet = snippet.slice(1);
133
+ }
134
+ return `\`\`\`js\n${snippet.join('\n')}\n\`\`\``;
135
+ }
136
+ const fileExists = (filepath) => __awaiter(void 0, void 0, void 0, function* () {
137
+ try {
138
+ yield access(filepath, fs.constants.F_OK);
139
+ return true;
140
+ }
141
+ catch (_a) {
142
+ return false;
143
+ }
144
+ });
145
+ const waitForFile = (filepath_1, ...args_1) => __awaiter(void 0, [filepath_1, ...args_1], void 0, function* (filepath, interval = 1000, timeout = 60000) {
146
+ const start = Date.now();
147
+ while (true) {
148
+ const now = Date.now();
149
+ if (now - start > timeout) {
150
+ throw new Error(`Timeout: ${filepath} did not become available within ${timeout}ms`);
151
+ }
152
+ if (yield fileExists(filepath)) {
153
+ const stats = [];
154
+ for (let i = 0; i < 2; i++) {
155
+ stats.push(yield stat(filepath));
156
+ yield new Promise((resolve) => setTimeout(resolve, interval));
157
+ }
158
+ const [first, second] = stats;
159
+ if (first.mtimeMs === second.mtimeMs &&
160
+ first.size === second.size) {
161
+ return;
162
+ }
163
+ }
164
+ yield new Promise((resolve) => setTimeout(resolve, interval));
165
+ }
166
+ });
167
+ const getBytes = (filePath) => __awaiter(void 0, void 0, void 0, function* () {
168
+ try {
169
+ yield waitForFile(filePath, 100, 5000);
170
+ return fs.readFileSync(filePath);
171
+ }
172
+ catch (err) {
173
+ console.error('Error reading file:', err);
174
+ throw err;
175
+ }
176
+ });
177
+ exports.getBytes = getBytes;
package/package.json CHANGED
@@ -1,8 +1,11 @@
1
1
  {
2
2
  "name": "@orangebeard-io/playwright-orangebeard-reporter",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "A Playwright reporter to report to Orangebeard.io",
5
5
  "main": "dist/index.js",
6
+ "files": [
7
+ "dist"
8
+ ],
6
9
  "scripts": {
7
10
  "build": "rimraf ./dist && tsc",
8
11
  "lint": "eslint . --ext .ts",
package/.eslintignore DELETED
@@ -1,5 +0,0 @@
1
- .idea/
2
- node_modules/*
3
- package.json
4
- package-lock.json
5
- dist/
package/.eslintrc DELETED
@@ -1,22 +0,0 @@
1
- {
2
- "parser": "@typescript-eslint/parser",
3
- "parserOptions": {
4
- "ecmaVersion": 12,
5
- "sourceType": "module",
6
- "project": "./tsconfig.json"
7
- },
8
- "plugins": ["@typescript-eslint", "prettier"],
9
- "extends": ["airbnb-base", "airbnb-typescript/base", "prettier", "eslint:recommended", "plugin:@typescript-eslint/recommended"],
10
- "rules": {
11
- "@typescript-eslint/no-unused-vars": "error",
12
- "@typescript-eslint/consistent-type-definitions": ["error", "type"],
13
- "@typescript-eslint/no-explicit-any": "off",
14
- "@typescript-eslint/no-namespace": "off",
15
- "@typescript-eslint/no-redeclare": "off",
16
- "prettier/prettier": 2
17
- },
18
- "env": {
19
- "browser": true,
20
- "es2021": true
21
- }
22
- }
package/.github/logo.svg DELETED
@@ -1,66 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
- <svg
3
- id="Layer_1"
4
- data-name="Layer 1"
5
- viewBox="0 0 348.01517 196.99"
6
- version="1.1"
7
- xml:space="preserve"
8
- width="348.01517"
9
- height="196.99001"
10
- xmlns="http://www.w3.org/2000/svg"
11
- xmlns:svg="http://www.w3.org/2000/svg"><defs
12
- id="defs4"><style
13
- id="style2">.cls-1{fill:#99425b;}.cls-2{fill:#fff;}.cls-3{fill:#e9551d;}.cls-4{fill:#ef7c10;}.cls-5{fill:#f6a307;}.cls-6{fill:#b91d1b;}.cls-7{fill:#020203;}</style></defs><path
14
- class="cls-3"
15
- d="M 132.43,25 A 67,67 0 0 1 144.27,62 62.44,62.44 0 0 0 127.81,43.48 72.41,72.41 0 0 1 136.37,79.81 32.55,32.55 0 0 0 122.56,60 c 4.3,10.75 8.43,23.54 2.07,33.22 a 93.11,93.11 0 0 0 -6,-15 81.23,81.23 0 0 1 -10.92,46 59.53,59.53 0 0 0 -8.2,-29.47 126.3,126.3 0 0 1 -5.71,38.43 101.78,101.78 0 0 0 -13.14,-33.15 133.18,133.18 0 0 1 -9.84,28.19 125.09,125.09 0 0 0 -9.87,-28 c -5.64,9.15 -4.66,20.73 -3.44,31.38 A 90.38,90.38 0 0 1 45.87,79.83 34.75,34.75 0 0 0 37.8,98 C 30.16,88.1 31.31,74.3 32.8,61.87 A 61.76,61.76 0 0 0 17.02,81.77 C 15.67,65 23.87,49.14 31.84,34.29 A 60.08,60.08 0 0 1 14.29,50.42 270.55,270.55 0 0 0 24.79,19 23.19,23.19 0 0 1 17.28,29.82 7.66,7.66 0 0 1 16.75,31.89 C 12.16,42.06 0.62,55.51 0,56.69 c 0,0 7.28,-0.82 12.33,-5.51 -7.81,14.92 5.05,42.72 11.21,49.74 -1.18,-3.18 -0.92,-7.67 1.84,-9.67 -1.35,29.05 22.88,46 22.88,46 0,0 -3.32,-6.56 -0.52,-10.25 1.57,8 35.9,19.14 35.9,35.14 0,-16.23 36.92,-28 40.76,-50.29 0.62,0 1.57,6.59 -0.33,9 17.58,-10.33 29.18,-43.12 27.9,-52.6 2.76,3 4.37,9.78 4.37,9.78 0,0 10.59,-24.5 -0.33,-45.12 C 151.88,25 147.94,21.5 144.5,19 c 1.11,5 3.64,9.58 6.13,14.07 A 26.36,26.36 0 0 0 132.43,25 Z"
16
- id="path10" /><path
17
- class="cls-4"
18
- d="M 78.56,22 C 40.72,21.08 26.2,9.63 26.2,0 c 0,17.83 -8.23,24 -8.92,29.83 A 23.19,23.19 0 0 0 24.79,19 270.55,270.55 0 0 1 14.29,50.38 60.08,60.08 0 0 0 31.84,34.29 C 23.87,49.14 15.67,65 17.02,81.77 A 61.35,61.35 0 0 1 32.79,61.9 c -1.48,12.43 -2.59,26.26 5,36.23 a 34.7,34.7 0 0 1 8.15,-18.2 90.45,90.45 0 0 0 11.61,51.84 c -1.18,-10.65 -2.2,-22.23 3.44,-31.38 a 124.08,124.08 0 0 1 9.87,28 133.07,133.07 0 0 0 9.84,-28.2 101.58,101.58 0 0 1 13.15,33.15 126.2,126.2 0 0 0 5.7,-38.43 59.88,59.88 0 0 1 8.2,29.48 81.17,81.17 0 0 0 10.92,-46 94.68,94.68 0 0 1 6,15 c 6.36,-9.7 2.23,-22.49 -2.06,-33.21 A 32.7,32.7 0 0 1 136.4,80 a 72.41,72.41 0 0 0 -8.56,-36.33 62.44,62.44 0 0 1 16.46,18.52 67.06,67.06 0 0 0 -11.83,-37 26.13,26.13 0 0 1 18.19,8.07 c -2.49,-4.49 -5,-9.08 -6.13,-14.07 -5.54,-3.93 -9.93,-5.44 -12.43,-19 C 132.07,9.63 116.43,22.91 78.56,22 Z"
19
- id="path12" /><path
20
- class="cls-5"
21
- d="m 57.94,28.22 c -6.69,5.81 -7.93,18.3 -6.65,27 a 21.76,21.76 0 0 1 6.25,-10.6 c -1.67,5 0.17,10.46 2.17,15.38 2.39,5.9 5.08,11.74 9,16.72 a 35.1,35.1 0 0 1 1.37,-20.53 c 0,2.46 1.32,4.73 2.5,6.89 a 119.6,119.6 0 0 1 11.8,31.58 c 5.34,-10.63 3.61,-23.38 7,-34.76 4.85,4.85 6.06,12.13 6.82,18.92 a 49.92,49.92 0 0 0 4.59,-28.53 29,29 0 0 1 7.9,12.71 46.24,46.24 0 0 0 -1,-23.38 c -1.48,-4.75 -4.07,-9.6 -8.63,-11.74 a 18.79,18.79 0 0 0 -5.54,-1.44 c -3.28,-0.46 -6.59,-0.72 -9.9,-1 A 64.1,64.1 0 0 0 73.39,25.34 21.75,21.75 0 0 0 62.14,29.7"
22
- id="path14" /><path
23
- class="cls-6"
24
- d="M 58.94,27.11 C 57.05,44 93.28,54.85 102.4,28.55 105.22,20.42 59.38,22.78 58.94,27.11 Z"
25
- id="path16" /><path
26
- class="cls-2"
27
- d="m 61.74,33.34 c 0,2.66 37.25,1.77 37.18,-0.66 0,-0.52 0.26,-6.13 0.3,-6.75 -10.46,0.56 -28.36,0.29 -37.51,3.08 v 4.33 z"
28
- id="path18" /><path
29
- class="cls-5"
30
- d="m 80.3,20.36 c 6.59,6.85 41.41,8.06 50.3,-2.53 -6.07,5.08 -14.14,4.56 -16.89,3.54 a 7.67,7.67 0 0 0 5.64,-5.9 C 104.17,30.78 99.71,4.52 80.5,18.55 64.63,7 54.2,23.37 42.1,17.7 l 5.15,3.67 c 0,0 -7.58,5 -16.89,-3.54 a 21.39,21.39 0 0 0 4.23,4.69 C 47.57,27 74.13,25.27 80.3,20.36 Z"
31
- id="path20" /><path
32
- class="cls-3"
33
- d="m 80.5,26.42 c 11.67,6.49 40.42,6.2 50.1,-8.56 v 0 c -8.89,10.56 -43.71,9.35 -50.3,2.5 -6.17,4.91 -32.73,6.64 -45.71,2.16 12.1,10.07 35.61,9.64 45.91,3.9 z"
34
- id="path22" /><path
35
- class="cls-3"
36
- d="m 84.46,156.66 c -6.75,3.77 -15.9,24.2 1.31,40.33 -1.31,-15.15 14.3,-23.81 -1.31,-40.33"
37
- id="path24" /><path
38
- class="cls-4"
39
- d="m 84.07,156.66 c -3.31,3.77 -6.72,24.2 1.74,40.33 -0.66,-15.15 5.9,-23.81 -1.74,-40.33"
40
- id="path26" /><path
41
- class="cls-7"
42
- d="m 64.53,153.41 c 1.34,-2.65 18.72,2.66 18.72,2.66 0,0 15.31,-6.1 18.1,-5.15 2.79,0.95 1.87,15.71 0,15.71 -1.87,0 -18.07,-8.27 -18.07,-8.27 0,0 -15.64,8.5 -17.18,8.27 C 64.56,166.4 63.74,155 64.53,153.41 Z"
43
- id="path28" /><g
44
- id="g7"
45
- transform="matrix(0.72207957,0,0,0.76886303,163.1628,22.418349)"><path
46
- d="m 84.380258,108.35161 c -9.556409,2.71207 -15.825994,7.46729 -19.95603,12.21879 3.955757,-3.46184 9.254573,-6.63891 16.402227,-8.66499 7.310808,-2.07206 13.547762,-2.05723 18.701222,-1.06273 v -4.02992 c -4.396274,-0.40195 -9.436267,-0.0816 -15.147419,1.53885 z M 63.987419,74.474785 28.496478,83.825026 c 0,0 0.646834,0.913665 1.844537,2.132875 l 30.091859,-7.929313 c 0,0 -0.426427,5.494602 -4.129516,10.410004 7.004745,-5.299557 7.684061,-13.963807 7.684061,-13.963807 z M 93.695643,157.8846 C 43.750467,171.33669 17.3261,113.45538 9.3258895,83.412689 5.6296968,69.545292 4.0161722,59.042587 3.5861115,52.264997 3.5399091,51.561208 3.5612675,50.967919 3.6110297,50.424317 1.020135,50.580797 -0.22028475,51.927564 0.03208571,55.819542 0.46214634,62.593424 2.075671,73.095387 5.7718637,86.967234 13.768515,117.00548 40.196441,174.88679 90.141839,161.43469 c 10.871291,-2.92862 19.038651,-8.26304 25.169561,-15.07252 -5.65108,5.10378 -12.72383,9.12331 -21.615757,11.52243 z M 103.08148,39.05096 v 3.554545 h 19.59042 c -0.40196,-1.258515 -0.80688,-2.392439 -1.20883,-3.554545 z"
47
- fill="#2d4552"
48
- id="path1" /><path
49
- d="m 127.05037,68.325341 c 8.81035,2.502198 13.46989,8.679082 15.93279,14.145502 l 9.82339,2.789943 c 0,0 -1.3401,-19.131357 -18.64486,-24.04676 -16.18865,-4.599476 -26.15072,8.995009 -27.36251,10.754111 4.70923,-3.355051 11.5862,-6.101981 20.25119,-3.642796 z m 78.19628,14.233753 c -16.20347,-4.620241 -26.16184,9.002425 -27.35583,10.737055 4.71294,-3.351344 11.5862,-6.099015 20.24748,-3.628706 8.79626,2.505906 13.4521,8.675373 15.92241,14.145497 l 9.83748,2.80033 c 0,0 -1.3616,-19.135065 -18.65154,-24.054176 z m -9.75961,50.442946 -81.71819,-22.84535 c 0,0 0.88474,4.48527 4.2791,10.29283 l 68.80302,19.23444 c 5.66443,-3.27718 8.63607,-6.68192 8.63607,-6.68192 z m -56.65543,49.17405 C 74.126734,164.82831 81.949255,82.385557 92.419329,43.318935 96.730318,27.219287 101.16219,15.252863 104.83762,7.2313679 102.64467,6.7799488 100.82846,7.9350832 99.033764,11.585074 95.131403,19.49985 90.141098,32.386837 85.311722,50.427284 74.844615,89.493164 67.022094,171.93295 131.72401,189.28073 c 30.4973,8.17033 54.25557,-4.24721 71.966,-23.74863 -16.81086,15.22603 -38.27384,23.76272 -64.8584,16.64399 z"
50
- fill="#2d4552"
51
- id="path2" /><path
52
- d="m 103.08148,138.56487 v -16.63658 l -46.223619,13.10725 c 0,0 3.415567,-19.84553 27.522397,-26.68393 7.310808,-2.07206 13.548504,-2.05797 18.701222,-1.06273 V 39.05096 h 23.14422 c -2.52,-7.786923 -4.95768,-13.782112 -7.00527,-17.947745 -3.38694,-6.894764 -6.85916,-2.324211 -14.74175,4.268717 C 98.926972,30.009972 84.895678,39.904555 63.781251,45.5942 42.666527,51.287553 25.596406,49.777632 18.474115,48.544332 8.3769974,46.802286 3.0956837,44.584867 3.5897454,52.264997 4.0197319,59.038879 5.6333307,69.541584 9.3295234,83.412689 17.3261,113.45167 43.754027,171.33298 93.699351,157.88089 106.74578,154.36565 115.95438,147.41749 122.33743,138.56116 H 103.08148 Z M 28.492993,83.825026 63.987419,74.474785 c 0,0 -1.034548,13.654555 -14.340768,17.162378 -13.309928,3.504116 -21.153658,-7.812137 -21.153658,-7.812137 z"
53
- fill="#e2574c"
54
- id="path3" /><path
55
- d="M 236.66429,39.840035 C 227.4379,41.45749 205.30301,43.472449 177.94792,36.140134 150.58542,28.812269 132.43076,15.996032 125.23787,9.9719198 115.04145,1.4315193 110.55619,-4.5037476 106.14211,4.473833 102.23975,12.392244 97.249446,25.27923 92.419329,43.319677 81.952963,82.385557 74.130442,164.82534 138.83161,182.17312 c 64.68783,17.33295 99.12605,-57.97772 109.59316,-97.047308 4.83012,-18.036738 6.94816,-31.695001 7.53107,-40.50164 0.66448,-9.976161 -6.18801,-7.080167 -19.29155,-4.784137 z M 106.66791,72.160957 c 0,0 10.19642,-15.858625 27.49007,-10.943223 17.30477,4.915403 18.64486,24.04676 18.64486,24.04676 z m 42.21477,71.162833 c -30.41869,-8.91046 -35.11013,-33.1671 -35.11013,-33.1671 l 81.71449,22.84609 c 0,-0.004 -16.49418,19.12023 -46.60436,10.32101 z m 28.89097,-49.849654 c 0,0 10.18232,-15.847501 27.473,-10.918008 17.28994,4.922819 18.65154,24.054172 18.65154,24.054172 z"
56
- fill="#2ead33"
57
- id="path4" /><path
58
- d="m 86.928436,126.50923 -30.070575,8.5226 c 0,0 3.266503,-18.60852 25.418445,-25.98311 L 65.248901,45.147008 63.777543,45.5942 C 42.662968,51.288295 25.592846,49.777632 18.470555,48.544332 8.3735118,46.803027 3.0921981,44.584867 3.5861857,52.265739 4.0162463,59.03962 5.6297709,69.541584 9.3259637,83.413431 17.322614,113.45167 43.750541,171.33298 93.695643,157.88089 L 95.167,157.41886 Z M 28.492993,83.825767 63.987419,74.474785 c 0,0 -1.034548,13.654555 -14.340768,17.162378 -13.309854,3.504116 -21.153658,-7.811396 -21.153658,-7.811396 z"
59
- fill="#d65348"
60
- id="path5" /><path
61
- d="m 150.25466,143.65752 -1.37569,-0.33447 c -30.41869,-8.90972 -35.11012,-33.16636 -35.11012,-33.16636 l 42.13689,11.77828 22.30842,-85.723641 -0.26994,-0.07119 C 150.58171,28.812269 132.4278,15.996032 125.23416,9.9719198 115.03775,1.4315193 110.55248,-4.5037476 106.1384,4.473833 102.23975,12.392244 97.249446,25.27923 92.419329,43.319677 81.952963,82.385557 74.130442,164.82534 138.83161,182.17238 l 1.32601,0.29887 z M 106.66791,72.160957 c 0,0 10.19642,-15.858625 27.49007,-10.943223 17.30477,4.915403 18.64486,24.04676 18.64486,24.04676 z"
62
- fill="#1d8d22"
63
- id="path6" /><path
64
- d="m 88.460606,126.07242 -8.064286,2.28861 c 1.9052,10.74002 5.263218,21.04694 10.533853,30.15245 0.917373,-0.20246 1.827331,-0.37674 2.761762,-0.63259 2.448802,-0.66078 4.719617,-1.47878 6.905885,-2.37094 -5.889136,-8.73915 -9.784822,-18.8043 -12.137214,-29.43753 z M 85.311722,50.428025 c -4.144126,15.467054 -7.851443,37.729496 -6.830985,60.059425 1.82659,-0.79278 3.756263,-1.53143 5.899521,-2.13955 l 1.492864,-0.33373 c -1.819915,-23.851711 2.114335,-48.157293 6.546207,-64.694493 1.123542,-4.183432 2.25005,-8.074668 3.37285,-11.703374 -1.808791,1.150981 -3.756263,2.330885 -5.974424,3.546387 -1.495831,4.617274 -3.006494,9.663942 -4.506033,15.265335 z"
65
- fill="#c04b41"
66
- id="path7" /></g></svg>
@@ -1,144 +0,0 @@
1
- name: release
2
-
3
- on:
4
- push:
5
- branches:
6
- - main
7
-
8
- jobs:
9
- get-version:
10
- runs-on: ubuntu-latest
11
- outputs:
12
- releaseVersion: ${{ steps.exposeVersion.outputs.releaseVersion }}
13
- steps:
14
- - name: Checkout repository
15
- uses: actions/checkout@v4
16
- - name: Setup Node.js
17
- uses: actions/setup-node@v4
18
- with:
19
- node-version: '20'
20
- - name: Cache node modules
21
- uses: actions/cache@v4
22
- with:
23
- path: node_modules
24
- key: node_modules-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
25
- restore-keys: |
26
- node_modules-
27
- - name: Install Node dependencies
28
- run: npm install
29
- - name: Get version from package.json
30
- id: exposeVersion
31
- run: echo "releaseVersion=$(npm run get-version --silent)" >> $GITHUB_OUTPUT
32
- prepare-release:
33
- needs: get-version
34
- runs-on: ubuntu-latest
35
- outputs:
36
- versionInfo: ${{ steps.readChangelogEntry.outputs.log_entry }}
37
- steps:
38
- - name: Checkout repository
39
- uses: actions/checkout@v4
40
- - name: Configure git
41
- run: |
42
- git config --global user.email "info@orangebeard.io"
43
- git config --global user.name "Orangebeard.io"
44
- - name: Create tag
45
- run: |
46
- git tag -a v${{ needs.get-version.outputs.releaseVersion }} -m ${{ needs.get-version.outputs.releaseVersion }}
47
- git push origin main --follow-tags
48
- - name: Setup Node.js
49
- uses: actions/setup-node@v4
50
- with:
51
- node-version: '20'
52
- - name: Cache node modules
53
- uses: actions/cache@v4
54
- with:
55
- path: node_modules
56
- key: node_modules-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
57
- restore-keys: |
58
- node_modules-
59
- - name: Install Node dependencies
60
- run: npm install
61
- - name: Create CHANGELOG.md
62
- run: npm run create-changelog
63
- - name: Upload changelog as artifact
64
- uses: actions/upload-artifact@v4
65
- with:
66
- name: changelog
67
- path: CHANGELOG.md
68
- create-release:
69
- needs: [get-version, prepare-release]
70
- runs-on: ubuntu-latest
71
- steps:
72
- - name: Checkout repository
73
- uses: actions/checkout@v4
74
- - name: Download changelog for artifact
75
- uses: actions/download-artifact@v4
76
- with:
77
- name: changelog
78
- - name: Create Release
79
- id: createRelease
80
- uses: ncipollo/release-action@v1
81
- env:
82
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
83
- with:
84
- tag: v${{ needs.get-version.outputs.releaseVersion }}
85
- name: ${{ needs.get-version.outputs.releaseVersion }}
86
- bodyFile: CHANGELOG.md
87
- publish-release:
88
- needs: [get-version, prepare-release, create-release]
89
- runs-on: ubuntu-latest
90
- permissions:
91
- contents: read
92
- id-token: write
93
- steps:
94
- - name: Checkout repository
95
- uses: actions/checkout@v4
96
- - name: Setup Node.js
97
- uses: actions/setup-node@v4
98
- with:
99
- node-version: '20'
100
- registry-url: 'https://registry.npmjs.org'
101
- - name: Cache node modules
102
- uses: actions/cache@v4
103
- with:
104
- path: node_modules
105
- key: node_modules-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
106
- restore-keys: |
107
- node_modules-
108
- - name: Transpile to JS
109
- run: npm run build
110
- - name: Install Node dependencies
111
- run: npm install
112
- - name: Publish to NPM
113
- run: npm publish --provenance --access public
114
- env:
115
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
116
- update-version:
117
- needs: [get-version, prepare-release, create-release, publish-release]
118
- runs-on: ubuntu-latest
119
- steps:
120
- - name: Checkout repository
121
- uses: actions/checkout@v4
122
- - name: Configure git
123
- run: |
124
- git config --global user.email "info@orangebeard.io"
125
- git config --global user.name "Orangebeard.io"
126
- - name: Setup Node.js
127
- uses: actions/setup-node@v4
128
- with:
129
- node-version: '20'
130
- - name: Cache node modules
131
- uses: actions/cache@v4
132
- with:
133
- path: node_modules
134
- key: node_modules-${{ runner.os }}-${{ hashFiles('**/package-lock.json') }}
135
- restore-keys: |
136
- node_modules-
137
- - name: Install Node dependencies
138
- run: npm install
139
- - name: Update version
140
- run: |
141
- npm run update-version
142
- git add package.json package-lock.json
143
- git commit -m "Update version"
144
- git push origin main
package/.prettierrc DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "arrowParens": "always",
3
- "singleQuote": true,
4
- "trailingComma": "all",
5
- "printWidth": 100,
6
- "endOfLine": "auto"
7
- }
@@ -1,29 +0,0 @@
1
- {{#each releases}}
2
- {{#if summary}}
3
- {{summary}}
4
- {{/if}}
5
-
6
- {{#if merges}}
7
- ### :twisted_rightwards_arrows: Merged
8
-
9
- {{#each merges}}
10
- - {{#if commit.breaking}}**Breaking change:** {{/if}}{{message}} {{#if href}}[`#{{id}}`]({{href}}){{/if}}
11
- {{/each}}
12
- {{/if}}
13
-
14
- {{#if fixes}}
15
- ### :bug: Fixed
16
-
17
- {{#each fixes}}
18
- - {{#if commit.breaking}}**Breaking change:** {{/if}}{{commit.subject}}{{#each fixes}} {{#if href}}[`#{{id}}`]({{href}}){{/if}}{{/each}}
19
- {{/each}}
20
- {{/if}}
21
-
22
- {{#commit-list commits heading='### :mag: Commits'}}
23
- - {{#if breaking}}**Breaking change:** {{/if}}{{subject}} {{#if href}}[`{{shorthash}}`]({{href}}){{/if}}
24
- {{/commit-list}}
25
-
26
- {{#if href}}
27
- See full comparison at [{{title}}]({{href}})
28
- {{/if}}
29
- {{/each}}
package/src/index.ts DELETED
@@ -1,3 +0,0 @@
1
- import {OrangebeardReporter} from "./reporter/OrangebeardReporter";
2
-
3
- export default OrangebeardReporter;
@@ -1,265 +0,0 @@
1
- import {UUID} from 'crypto';
2
- import {Reporter, TestCase, TestResult, TestStep} from '@playwright/test/reporter'
3
- import {ansiToMarkdown, getBytes, getCodeSnippet, getTime, removeAnsi, testStatusMap} from './utils'
4
- import {OrangebeardParameters} from "@orangebeard-io/javascript-client/dist/client/models/OrangebeardParameters";
5
- import OrangebeardAsyncV3Client from "@orangebeard-io/javascript-client/dist/client/OrangebeardAsyncV3Client";
6
- import {StartTest} from "@orangebeard-io/javascript-client/dist/client/models/StartTest";
7
- import {Attachment} from "@orangebeard-io/javascript-client/dist/client/models/Attachment";
8
- import {Log} from "@orangebeard-io/javascript-client/dist/client/models/Log";
9
- import {Attribute} from "@orangebeard-io/javascript-client/dist/client/models/Attribute";
10
- import {FinishStep} from "@orangebeard-io/javascript-client/dist/client/models/FinishStep";
11
- import TestType = StartTest.TestType;
12
- import LogFormat = Log.LogFormat;
13
- import LogLevel = Log.LogLevel;
14
- import Status = FinishStep.Status;
15
- import * as path from "node:path";
16
-
17
- export class OrangebeardReporter implements Reporter {
18
-
19
- config: OrangebeardParameters;
20
- client: OrangebeardAsyncV3Client;
21
-
22
- //CONTEXT TRACKING
23
- testRunId: UUID;
24
- suites: Map<string, UUID> = new Map<string, UUID>(); //suiteNames , uuid
25
- tests: Map<string, UUID> = new Map<string, UUID>(); //testId, uuid
26
- steps: Map<string, UUID> = new Map<string, UUID>(); //testId_stepPath, uuid
27
- promises: Promise<void>[] = [];
28
-
29
- constructor() {
30
- this.client = new OrangebeardAsyncV3Client();
31
- this.config = this.client.config;
32
- }
33
-
34
- onBegin(): void {
35
- this.testRunId = this.client.startTestRun({
36
- testSetName: this.config.testset,
37
- description: this.config.description,
38
- startTime: getTime(),
39
- attributes: this.config.attributes
40
- })
41
- }
42
-
43
- async onEnd(): Promise<void> {
44
- await Promise.all(this.promises)
45
- return this.client.finishTestRun(this.testRunId, {endTime: getTime()})
46
- }
47
-
48
- onStdErr(chunk: string | Buffer, test: void | TestCase, _result: void | TestResult): void {
49
- //log error level
50
-
51
- if (typeof test === 'object' && test !== null) {
52
- const testUUID = this.tests.get(test.id);
53
- const message = chunk.toString();
54
- this.client.log({
55
- logFormat: LogFormat.PLAIN_TEXT,
56
- logLevel: LogLevel.ERROR,
57
- logTime: getTime(),
58
- message: message,
59
- testRunUUID: this.testRunId,
60
- testUUID: testUUID
61
- });
62
- }
63
- }
64
-
65
- onStdOut(chunk: string | Buffer, test: void | TestCase, _result: void | TestResult): void {
66
- if (typeof test === 'object' && test !== null) {
67
- const testUUID = this.tests.get(test.id);
68
- const message = chunk.toString();
69
- this.client.log({
70
- logFormat: LogFormat.PLAIN_TEXT,
71
- logLevel: LogLevel.INFO,
72
- logTime: getTime(),
73
- message: message,
74
- testRunUUID: this.testRunId,
75
- testUUID: testUUID
76
- });
77
- }
78
- }
79
-
80
- onStepBegin(test: TestCase, _result: TestResult, step: TestStep): void {
81
- //start step
82
- const testUUID = this.tests.get(test.id);
83
-
84
- const stepUUID = this.client.startStep({
85
- startTime: getTime(),
86
- stepName: step.title || step.titlePath().toString() || 'Untitled step',
87
- description: step.location ? `${path.basename(step.location.file)}:${step.location.line}`: undefined,
88
- testRunUUID: this.testRunId,
89
- testUUID: testUUID,
90
- parentStepUUID: step.parent ? this.steps.get(test.id + "|" + step.parent.titlePath()) : undefined,
91
- })
92
- this.steps.set(test.id + "|" + step.titlePath(), stepUUID)
93
-
94
- if(step.location) {
95
- this.client.log({
96
- logFormat: LogFormat.MARKDOWN,
97
- logLevel: LogLevel.INFO,
98
- logTime: getTime(),
99
- message: getCodeSnippet(step.location.file, step.location.line),
100
- testRunUUID: this.testRunId,
101
- testUUID: testUUID,
102
- stepUUID: stepUUID
103
- });
104
- }
105
- }
106
-
107
- onStepEnd(test: TestCase, _result: TestResult, step: TestStep): void {
108
- const testUUID = this.tests.get(test.id);
109
- const stepUUID = this.steps.get(test.id + "|" + step.titlePath())
110
- if(step.error) {
111
- const message = step.error.message;
112
- this.client.log({
113
- logFormat: LogFormat.MARKDOWN,
114
- logLevel: LogLevel.ERROR,
115
- logTime: getTime(),
116
- message: ansiToMarkdown(message),
117
- testRunUUID: this.testRunId,
118
- testUUID: testUUID,
119
- stepUUID: stepUUID
120
- });
121
-
122
- if (step.error.snippet) {
123
- this.client.log({
124
- logFormat: LogFormat.MARKDOWN,
125
- logLevel: LogLevel.ERROR,
126
- logTime: getTime(),
127
- message: `\`\`\`js\n${removeAnsi(step.error.snippet)}\n\`\`\``,
128
- testRunUUID: this.testRunId,
129
- testUUID: testUUID,
130
- stepUUID: stepUUID
131
- });
132
- }
133
- }
134
-
135
- this.client.finishStep(this.steps.get(test.id + "|" + step.titlePath()), {
136
- endTime: getTime(),
137
- status: step.error ? Status.FAILED : Status.PASSED,
138
- testRunUUID: this.testRunId
139
- })
140
- this.steps.delete(test.id + "|" + step.titlePath())
141
- }
142
-
143
- onTestBegin(test: TestCase): void {
144
- //check suite
145
- const suiteUUID = this.getOrStartSuite(test.parent.titlePath())
146
- const attributes: Array<Attribute> = [];
147
- for (const tag of test.tags) {
148
- attributes.push({value: tag})
149
- }
150
- const testUUID = this.client.startTest({
151
- testType: TestType.TEST,
152
- testRunUUID: this.testRunId,
153
- suiteUUID: suiteUUID,
154
- testName: test.title,
155
- startTime: getTime(),
156
- description: this.getTestDescription(test),
157
- attributes: attributes
158
- });
159
- this.tests.set(test.id, testUUID);
160
- }
161
-
162
- async onTestEnd(test: TestCase, result: TestResult): Promise<void> {
163
- const testUUID = this.tests.get(test.id);
164
- if (result.attachments.length > 0) {
165
- let message = "";
166
- for (const attachment of result.attachments) {
167
- message += `- ${attachment.name} (${attachment.contentType})\n`
168
- }
169
- const attachmentsLogUUID = this.client.log({
170
- logFormat: LogFormat.MARKDOWN,
171
- logLevel: LogLevel.INFO,
172
- logTime: getTime(),
173
- message: message,
174
- testRunUUID: this.testRunId,
175
- testUUID: testUUID
176
- })
177
- for (const attachment of result.attachments) {
178
- this.promises.push(this.logAttachment(attachment, testUUID, attachmentsLogUUID));
179
- }
180
- }
181
-
182
- //determine status
183
- const status = testStatusMap[result.status]
184
-
185
- //finish test
186
- this.client.finishTest(testUUID, {
187
- testRunUUID: this.testRunId,
188
- status: status,
189
- endTime: getTime()
190
- });
191
- this.tests.delete(test.id);
192
- }
193
-
194
- printsToStdio(): boolean {
195
- return false;
196
- }
197
-
198
- private getOrStartSuite(suitePath: Array<string>): UUID {
199
- const filteredSuitePath = suitePath.filter(name => name !== "");
200
- let currentPath: Array<string> = [];
201
- let parentSuiteUUID: UUID | undefined = undefined;
202
-
203
- for (const suiteName of filteredSuitePath) {
204
- currentPath.push(suiteName);
205
- const existingSuiteUUID = this.suites.get(currentPath.join('|'));
206
-
207
- if (existingSuiteUUID) {
208
- parentSuiteUUID = existingSuiteUUID;
209
- } else {
210
- const newSuitesUUIDs = this.client.startSuite({
211
- testRunUUID: this.testRunId,
212
- parentSuiteUUID: parentSuiteUUID,
213
- suiteNames: [suiteName],
214
- });
215
-
216
- if (newSuitesUUIDs && newSuitesUUIDs.length > 0) {
217
- parentSuiteUUID = newSuitesUUIDs[0];
218
- this.suites.set(currentPath.join('|'), parentSuiteUUID);
219
- } else {
220
- console.error(`Failed to create suite for path: ${currentPath.join(' > ')}`);
221
- }
222
- }
223
- }
224
- return parentSuiteUUID as UUID;
225
- }
226
-
227
- private getTestDescription(test: TestCase): string {
228
- let description = `${path.basename(test.location.file)}:${test.location.line}\n`;
229
- for (const annotation of test.annotations) {
230
- description = `${description + annotation.type}: ${annotation.description}\n`
231
- }
232
- return description;
233
- }
234
-
235
- private async logAttachment(attachment: {
236
- name: string,
237
- path?: string,
238
- body?: Buffer,
239
- contentType: string
240
- }, testUUID: UUID, logUUID: UUID) {
241
- let content: Buffer;
242
- if (attachment.body) {
243
- content = attachment.body;
244
- } else if (attachment.path) {
245
- content = await getBytes(attachment.path);
246
- } else {
247
- throw new Error("Attachment must have either body or path defined.");
248
- }
249
-
250
- const orangebeardAttachment: Attachment = {
251
- file: {
252
- name: path.basename(attachment.path),
253
- content: content,
254
- contentType: attachment.contentType,
255
- },
256
- metaData: {
257
- testRunUUID: this.testRunId,
258
- testUUID: testUUID,
259
- logUUID: logUUID,
260
- attachmentTime: getTime()
261
- },
262
- };
263
- this.client.sendAttachment(orangebeardAttachment);
264
- }
265
- }
@@ -1,160 +0,0 @@
1
- import {ZonedDateTime} from "@js-joda/core";
2
- import {FinishTest} from "@orangebeard-io/javascript-client/dist/client/models/FinishTest";
3
- import * as fs from "node:fs";
4
- import {promisify} from "util";
5
- import Status = FinishTest.Status;
6
-
7
- const stat = promisify(fs.stat);
8
- const access = promisify(fs.access);
9
-
10
- export function getTime() {
11
- return ZonedDateTime.now().withFixedOffsetZone().toString();
12
- }
13
-
14
- export const testStatusMap = {
15
- "passed": Status.PASSED,
16
- "failed": Status.FAILED,
17
- "timedOut": Status.TIMED_OUT,
18
- "skipped": Status.SKIPPED,
19
- "interrupted": Status.STOPPED
20
- };
21
-
22
- export function removeAnsi(ansiString: string): string {
23
- const parts = ansiString.split(/(\u001b\[[0-9;]*[mG])/);
24
- let result = "";
25
- for (const part of parts) {
26
- if (!part.startsWith("\u001b[")) {
27
- result += part;
28
- }
29
- }
30
- return result;
31
- }
32
-
33
- export function ansiToMarkdown(ansiString: string): string {
34
- let markdown = "";
35
- let currentStyle: { italic?: boolean, code?: boolean } = {};
36
-
37
- const ansiCodes = {
38
- "31": {italic: true},
39
- "32": {italic: true},
40
- "39": {italic: false}, // Reset styles
41
- "2": {code: true},
42
- "22": {code: false},
43
- };
44
-
45
- const parts = ansiString.split(/(\u001b\[[0-9;]*[mG])/);
46
-
47
- for (const part of parts) {
48
- if (part.startsWith("\u001b[")) {
49
- const code = part.slice(2, -1);
50
- const codes = code.split(';');
51
- for (const c of codes) {
52
- const style = ansiCodes[c as keyof typeof ansiCodes]; // Type guard
53
- if (style) {
54
- currentStyle = {...currentStyle, ...style};
55
- }
56
- }
57
- } else {
58
- let formattedPart = part.replace(/\n/g, " \n");
59
-
60
- if (currentStyle.italic) {
61
- formattedPart = formattedPart.endsWith(" ") ? `*${formattedPart.trim()}* ` : `*${formattedPart}*`;
62
-
63
- }
64
- if (currentStyle.code) {
65
- formattedPart = `${formattedPart}`;
66
- }
67
-
68
- markdown += formattedPart
69
-
70
- }
71
- }
72
-
73
- return markdown;
74
- }
75
-
76
- /**
77
- * Reads a 3-line snippet from a file, centered around the specified line number.
78
- *
79
- * @param filePath - The path to the file.
80
- * @param lineNumber - The line number to center the snippet around (1-based index).
81
- * @returns A promise that resolves with the 3-line snippet or an error message if the line is out of range.
82
- */
83
- export /**
84
- * Reads a 3-line snippet from a file, centered around the specified line number.
85
- *
86
- * @param filePath - The path to the file.
87
- * @param lineNumber - The line number to center the snippet around (1-based index).
88
- * @returns The 3-line snippet or an error message if the line is out of range.
89
- */
90
- function getCodeSnippet(filePath: string, lineNumber: number): string {
91
- if (lineNumber < 1) {
92
- throw new Error('Line number must be 1 or greater.');
93
- }
94
-
95
- const fileContent = fs.readFileSync(filePath, 'utf8');
96
- const lines = fileContent.split(/\r?\n/); // Support both Unix and Windows line endings
97
-
98
- const startLine = Math.max(0, lineNumber - 2); // Zero-based index for one line before
99
- const endLine = Math.min(lines.length, lineNumber + 1); // One line after
100
-
101
- if (startLine >= lines.length) {
102
- throw new Error('Line number is out of range.');
103
- }
104
-
105
- let snippet = lines.slice(startLine, endLine);
106
- if (snippet.length > 0 && snippet[0].trim() === "") {
107
- snippet = snippet.slice(1);
108
- }
109
-
110
- return `\`\`\`js\n${snippet.join('\n')}\n\`\`\``;
111
- }
112
-
113
- const fileExists = async (filepath: string) => {
114
- try {
115
- await access(filepath, fs.constants.F_OK);
116
- return true;
117
- } catch {
118
- return false;
119
- }
120
- };
121
-
122
- const waitForFile = async (filepath: string, interval = 1000, timeout = 60000) => {
123
- const start = Date.now();
124
-
125
- while (true) {
126
- const now = Date.now();
127
- if (now - start > timeout) {
128
- throw new Error(`Timeout: ${filepath} did not become available within ${timeout}ms`);
129
- }
130
-
131
- if (await fileExists(filepath)) {
132
- const stats = [];
133
- for (let i = 0; i < 2; i++) {
134
- stats.push(await stat(filepath));
135
- await new Promise((resolve) => setTimeout(resolve, interval));
136
- }
137
-
138
- const [first, second] = stats;
139
- if (
140
- first.mtimeMs === second.mtimeMs &&
141
- first.size === second.size
142
- ) {
143
- return;
144
- }
145
- }
146
-
147
- await new Promise((resolve) => setTimeout(resolve, interval));
148
- }
149
- };
150
-
151
- export const getBytes = async (filePath: string) => {
152
- try {
153
- await waitForFile(filePath, 100, 5000)
154
- return fs.readFileSync(filePath);
155
- } catch (err) {
156
- console.error('Error reading file:', err);
157
- throw err;
158
- }
159
- };
160
-
package/tsconfig.json DELETED
@@ -1,20 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "es6",
4
- "module": "commonjs",
5
- "allowJs": false,
6
- "outDir": "dist",
7
- "rootDir": "src",
8
- "noImplicitAny": true,
9
- "esModuleInterop": true,
10
- "resolveJsonModule": true,
11
- "moduleResolution": "node",
12
- "baseUrl": ".",
13
- "paths": {
14
- "*": ["node_modules/*"]
15
- },
16
- "typeRoots": ["./node_modules/@types"]
17
- },
18
- "include": ["./src/**/*"],
19
- "exclude": ["node_modules"],
20
- }