@bigbinary/neeto-playwright-reporter 1.0.2 → 1.1.0
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/index.cjs.js +31 -18
- package/index.cjs.js.map +1 -1
- package/index.d.ts +1 -1
- package/index.js +30 -17
- package/index.js.map +1 -1
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ declare class MyReporter implements Reporter {
|
|
|
13
13
|
constructor(options: ReporterOptionParams);
|
|
14
14
|
onBegin: (config: FullConfig, rootSuite: Suite) => Promise<void>;
|
|
15
15
|
onTestBegin: ({ id, title }: TestCase, { retry }: TestResult) => Promise<void>;
|
|
16
|
-
onTestEnd: ({ id, title }: TestCase, { status, duration, errors, retry }: TestResult) => Promise<void>;
|
|
16
|
+
onTestEnd: ({ id, title }: TestCase, { status, duration, errors, retry, attachments }: TestResult) => Promise<void>;
|
|
17
17
|
onEnd: ({ status, duration }: FullResult) => Promise<void>;
|
|
18
18
|
}
|
|
19
19
|
|
package/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import require$$6 from 'fs';
|
|
1
2
|
import require$$1, { TextEncoder } from 'util';
|
|
2
3
|
import stream, { Readable } from 'stream';
|
|
3
4
|
import require$$1$1 from 'path';
|
|
4
5
|
import require$$3 from 'http';
|
|
5
6
|
import require$$4 from 'https';
|
|
6
7
|
import require$$0$1 from 'url';
|
|
7
|
-
import require$$6 from 'fs';
|
|
8
8
|
import require$$4$1 from 'assert';
|
|
9
9
|
import require$$1$2 from 'tty';
|
|
10
10
|
import require$$0$2 from 'os';
|
|
@@ -18439,12 +18439,8 @@ const HEADERS_KEYS = {
|
|
|
18439
18439
|
};
|
|
18440
18440
|
const API_BASE_URL = "/api/v1";
|
|
18441
18441
|
|
|
18442
|
-
const create$2 = (ciBuildId, history_id, payload) => axios.post(`${API_BASE_URL}/reporter/runs/${ciBuildId}/test_entities/${history_id}/attempts`, {
|
|
18443
|
-
|
|
18444
|
-
});
|
|
18445
|
-
const update$1 = (ciBuildId, history_id, id, payload) => axios.put(`${API_BASE_URL}/reporter/runs/${ciBuildId}/test_entities/${history_id}/attempts/${id}`, {
|
|
18446
|
-
attempt: payload,
|
|
18447
|
-
});
|
|
18442
|
+
const create$2 = (ciBuildId, history_id, payload) => axios.post(`${API_BASE_URL}/reporter/runs/${ciBuildId}/test_entities/${history_id}/attempts`, payload, { headers: { "Content-Type": "multipart/form-data" } });
|
|
18443
|
+
const update$1 = (ciBuildId, history_id, id, payload) => axios.put(`${API_BASE_URL}/reporter/runs/${ciBuildId}/test_entities/${history_id}/attempts/${id}`, payload, { headers: { "Content-Type": "multipart/form-data" } });
|
|
18448
18444
|
const attemptsApi = { create: create$2, update: update$1 };
|
|
18449
18445
|
|
|
18450
18446
|
const ERRORS = {
|
|
@@ -18496,6 +18492,7 @@ const executeCommandLine = ({ command, messageOnError, shouldThrowError = false,
|
|
|
18496
18492
|
const createShardObject = ({ currentShard = 0, status = "running", duration = null, }) => ({
|
|
18497
18493
|
[currentShard]: { status, duration },
|
|
18498
18494
|
});
|
|
18495
|
+
const convertBufferToBlob = (buffer, contentType) => new Blob([buffer], { type: contentType });
|
|
18499
18496
|
|
|
18500
18497
|
const getDescribePath = ({ titlePath, title, project, spec, }) => titlePath.filter((item, index) => index !== 0 && item !== title && item !== project && item !== spec);
|
|
18501
18498
|
const getCurrentCommitSha = () => executeCommandLine({
|
|
@@ -18562,7 +18559,8 @@ class MyReporter {
|
|
|
18562
18559
|
test_entities: getInitializerData(config, rootSuite),
|
|
18563
18560
|
}));
|
|
18564
18561
|
}
|
|
18565
|
-
catch (
|
|
18562
|
+
catch (error) {
|
|
18563
|
+
consoleLogFormatted.error(error);
|
|
18566
18564
|
throw new Error(ERRORS.onBegin.failedToInitializeRun);
|
|
18567
18565
|
}
|
|
18568
18566
|
consoleLogFormatted.underline(MESSAGES.onBegin.testStarted);
|
|
@@ -18577,28 +18575,42 @@ class MyReporter {
|
|
|
18577
18575
|
};
|
|
18578
18576
|
this.onTestBegin = async ({ id, title }, { retry }) => {
|
|
18579
18577
|
try {
|
|
18578
|
+
const formData = new FormData();
|
|
18579
|
+
formData.append("attempt[status]", "running");
|
|
18580
18580
|
retry === 0 &&
|
|
18581
|
-
(await attemptsApi.update(this.ciBuildId, id, this.attempts[id],
|
|
18582
|
-
status: "running",
|
|
18583
|
-
}));
|
|
18581
|
+
(await attemptsApi.update(this.ciBuildId, id, this.attempts[id], formData));
|
|
18584
18582
|
}
|
|
18585
|
-
catch (
|
|
18583
|
+
catch (error) {
|
|
18586
18584
|
consoleLogFormatted.error(ERRORS.onTestBegin.failedToReportTest(title, id));
|
|
18585
|
+
console.log(error);
|
|
18587
18586
|
}
|
|
18588
18587
|
};
|
|
18589
|
-
this.onTestEnd = async ({ id, title }, { status, duration, errors, retry }) => {
|
|
18588
|
+
this.onTestEnd = async ({ id, title }, { status, duration, errors, retry, attachments }) => {
|
|
18590
18589
|
try {
|
|
18591
18590
|
const testResult = {
|
|
18592
18591
|
status,
|
|
18593
18592
|
duration,
|
|
18594
18593
|
log: errors.map(error => { var _a; return (_a = error.message) !== null && _a !== void 0 ? _a : ""; }).join("\n"),
|
|
18595
18594
|
};
|
|
18595
|
+
consoleLogFormatted.underline(title);
|
|
18596
|
+
const formData = new FormData();
|
|
18597
|
+
attachments.map(({ name, path, body, contentType }) => {
|
|
18598
|
+
consoleLogFormatted.dim(`${name}: ${path}`);
|
|
18599
|
+
if (["screenshot", "video", "trace"].includes(name)) {
|
|
18600
|
+
const buffer = path ? require$$6.readFileSync(path) : body;
|
|
18601
|
+
formData.append(`attempt[${name}s][]`, convertBufferToBlob(buffer, contentType));
|
|
18602
|
+
}
|
|
18603
|
+
});
|
|
18604
|
+
Object.entries(testResult).map(([resultKey, resultValue]) => {
|
|
18605
|
+
formData.append(`attempt[${resultKey}]`, resultValue.toString());
|
|
18606
|
+
});
|
|
18596
18607
|
retry === 0
|
|
18597
|
-
? await attemptsApi.update(this.ciBuildId, id, this.attempts[id],
|
|
18598
|
-
: await attemptsApi.create(this.ciBuildId, id,
|
|
18608
|
+
? await attemptsApi.update(this.ciBuildId, id, this.attempts[id], formData)
|
|
18609
|
+
: await attemptsApi.create(this.ciBuildId, id, formData);
|
|
18599
18610
|
}
|
|
18600
|
-
catch (
|
|
18611
|
+
catch (error) {
|
|
18601
18612
|
consoleLogFormatted.error(ERRORS.onTestBegin.failedToReportTest(title, id));
|
|
18613
|
+
console.log(error);
|
|
18602
18614
|
}
|
|
18603
18615
|
};
|
|
18604
18616
|
this.onEnd = async ({ status, duration }) => {
|
|
@@ -18611,7 +18623,8 @@ class MyReporter {
|
|
|
18611
18623
|
}),
|
|
18612
18624
|
});
|
|
18613
18625
|
}
|
|
18614
|
-
catch (
|
|
18626
|
+
catch (error) {
|
|
18627
|
+
console.log(error);
|
|
18615
18628
|
throw new Error(ERRORS.onEnd.failedToReportRunStatus);
|
|
18616
18629
|
}
|
|
18617
18630
|
};
|