@sentinelqa/playwright-reporter 0.1.23 → 0.1.24
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/dist/reporter.js +4 -61
- package/package.json +1 -1
- package/dist/reportServer.d.ts +0 -1
- package/dist/reportServer.js +0 -70
package/dist/reporter.js
CHANGED
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
|
-
const child_process_1 = require("child_process");
|
|
6
|
-
const net_1 = __importDefault(require("net"));
|
|
7
5
|
const path_1 = __importDefault(require("path"));
|
|
8
6
|
const url_1 = require("url");
|
|
9
7
|
const node_1 = require("@sentinelqa/uploader/node");
|
|
@@ -28,47 +26,6 @@ const cyan = (value) => colorize(value, "36");
|
|
|
28
26
|
const yellow = (value) => colorize(value, "33");
|
|
29
27
|
const dim = (value) => colorize(value, "2");
|
|
30
28
|
const magenta = (value) => colorize(value, "35");
|
|
31
|
-
const getAvailablePort = () => {
|
|
32
|
-
return new Promise((resolve, reject) => {
|
|
33
|
-
const server = net_1.default.createServer();
|
|
34
|
-
server.unref();
|
|
35
|
-
server.on("error", reject);
|
|
36
|
-
server.listen(0, "127.0.0.1", () => {
|
|
37
|
-
const address = server.address();
|
|
38
|
-
if (!address || typeof address === "string") {
|
|
39
|
-
server.close(() => reject(new Error("Failed to acquire a local port")));
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
const port = address.port;
|
|
43
|
-
server.close((error) => {
|
|
44
|
-
if (error) {
|
|
45
|
-
reject(error);
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
resolve(port);
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
};
|
|
53
|
-
const startLocalReportServer = async (localReportPath) => {
|
|
54
|
-
const port = await getAvailablePort();
|
|
55
|
-
const reportServerPath = require.resolve("./reportServer");
|
|
56
|
-
const rootDir = process.cwd();
|
|
57
|
-
const relativeReportPath = path_1.default.relative(rootDir, localReportPath).replace(/\\/g, "/");
|
|
58
|
-
const reportUrlPath = relativeReportPath.startsWith("/")
|
|
59
|
-
? relativeReportPath
|
|
60
|
-
: `/${relativeReportPath}`;
|
|
61
|
-
const child = (0, child_process_1.spawn)(process.execPath, [reportServerPath, "--root", rootDir, "--port", String(port)], {
|
|
62
|
-
detached: true,
|
|
63
|
-
stdio: "ignore"
|
|
64
|
-
});
|
|
65
|
-
child.unref();
|
|
66
|
-
return `http://127.0.0.1:${port}${reportUrlPath}`;
|
|
67
|
-
};
|
|
68
|
-
const updateRedirectPage = (redirectPath, targetUrl) => {
|
|
69
|
-
const escapedTarget = targetUrl.replace(/"/g, """);
|
|
70
|
-
require("fs").writeFileSync(redirectPath, `<!doctype html><html lang="en"><head><meta charset="utf-8" /><meta http-equiv="refresh" content="0; url=${escapedTarget}" /><title>Sentinel Playwright Reporter</title></head><body><p>Open <a href="${escapedTarget}">${escapedTarget}</a>.</p></body></html>`, "utf8");
|
|
71
|
-
};
|
|
72
29
|
class SentinelReporter {
|
|
73
30
|
constructor(options) {
|
|
74
31
|
this.failedCount = 0;
|
|
@@ -99,29 +56,23 @@ class SentinelReporter {
|
|
|
99
56
|
this.failedCount += 1;
|
|
100
57
|
}
|
|
101
58
|
}
|
|
102
|
-
printLocalReport(localReportPath
|
|
59
|
+
printLocalReport(localReportPath) {
|
|
103
60
|
const relativeReportPath = path_1.default
|
|
104
61
|
.relative(process.cwd(), localReportPath)
|
|
105
62
|
.replace(/\\/g, "/");
|
|
106
63
|
const displayPath = relativeReportPath.startsWith(".")
|
|
107
64
|
? relativeReportPath
|
|
108
65
|
: `./${relativeReportPath}`;
|
|
109
|
-
const
|
|
110
|
-
const openCommand = `open ${displayTarget}`;
|
|
66
|
+
const openCommand = `open ${displayPath}`;
|
|
111
67
|
console.log("");
|
|
112
68
|
console.log(green("✔ Artifacts collected"));
|
|
113
69
|
console.log(green("✔ Sentinel HTML debugging report created"));
|
|
114
70
|
console.log("");
|
|
115
71
|
console.log(bold("Report"));
|
|
116
|
-
console.log(` ${cyan(formatTerminalLink(
|
|
72
|
+
console.log(` ${cyan(formatTerminalLink(displayPath, (0, url_1.pathToFileURL)(localReportPath).href))}`);
|
|
117
73
|
console.log("");
|
|
118
74
|
console.log(bold("Open"));
|
|
119
75
|
console.log(` ${cyan(openCommand)}`);
|
|
120
|
-
if (localReportUrl) {
|
|
121
|
-
console.log("");
|
|
122
|
-
console.log(yellow("Trace Viewer"));
|
|
123
|
-
console.log(` ${dim("Open the localhost report URL above so 'View Trace' works correctly.")}`);
|
|
124
|
-
}
|
|
125
76
|
console.log("");
|
|
126
77
|
console.log(yellow("Tip"));
|
|
127
78
|
console.log(` ${dim("Upload runs to Sentinel Cloud for CI history,")}`);
|
|
@@ -147,15 +98,7 @@ class SentinelReporter {
|
|
|
147
98
|
reportFileName: this.options.localReportFileName,
|
|
148
99
|
redirectFileName: this.options.localRedirectFileName
|
|
149
100
|
});
|
|
150
|
-
|
|
151
|
-
try {
|
|
152
|
-
localReportUrl = await startLocalReportServer(localReport.htmlPath);
|
|
153
|
-
updateRedirectPage(localReport.redirectPath, localReportUrl);
|
|
154
|
-
}
|
|
155
|
-
catch {
|
|
156
|
-
localReportUrl = undefined;
|
|
157
|
-
}
|
|
158
|
-
this.printLocalReport(localReport.htmlPath, localReportUrl);
|
|
101
|
+
this.printLocalReport(localReport.htmlPath);
|
|
159
102
|
console.log("");
|
|
160
103
|
if (hasSentinelToken && !hasCiEnv && !localUploadEnabled) {
|
|
161
104
|
console.log("Sentinel upload skipped for this local run.");
|
package/package.json
CHANGED
package/dist/reportServer.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/reportServer.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const fs_1 = __importDefault(require("fs"));
|
|
7
|
-
const http_1 = __importDefault(require("http"));
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const MIME_TYPES = {
|
|
10
|
-
".css": "text/css; charset=utf-8",
|
|
11
|
-
".gif": "image/gif",
|
|
12
|
-
".html": "text/html; charset=utf-8",
|
|
13
|
-
".jpeg": "image/jpeg",
|
|
14
|
-
".jpg": "image/jpeg",
|
|
15
|
-
".js": "text/javascript; charset=utf-8",
|
|
16
|
-
".json": "application/json; charset=utf-8",
|
|
17
|
-
".mjs": "text/javascript; charset=utf-8",
|
|
18
|
-
".mp4": "video/mp4",
|
|
19
|
-
".png": "image/png",
|
|
20
|
-
".svg": "image/svg+xml",
|
|
21
|
-
".txt": "text/plain; charset=utf-8",
|
|
22
|
-
".webm": "video/webm",
|
|
23
|
-
".xml": "application/xml; charset=utf-8",
|
|
24
|
-
".zip": "application/zip"
|
|
25
|
-
};
|
|
26
|
-
const rootIndex = process.argv.indexOf("--root");
|
|
27
|
-
const portIndex = process.argv.indexOf("--port");
|
|
28
|
-
if (rootIndex === -1 || portIndex === -1) {
|
|
29
|
-
throw new Error("Expected --root and --port arguments");
|
|
30
|
-
}
|
|
31
|
-
const rootDir = path_1.default.resolve(process.argv[rootIndex + 1] || process.cwd());
|
|
32
|
-
const port = Number(process.argv[portIndex + 1]);
|
|
33
|
-
if (!Number.isInteger(port) || port <= 0) {
|
|
34
|
-
throw new Error("Expected a valid port");
|
|
35
|
-
}
|
|
36
|
-
const send = (res, statusCode, body) => {
|
|
37
|
-
res.writeHead(statusCode, { "Content-Type": "text/plain; charset=utf-8" });
|
|
38
|
-
res.end(body);
|
|
39
|
-
};
|
|
40
|
-
const server = http_1.default.createServer((req, res) => {
|
|
41
|
-
const requestPath = req.url ? req.url.split("?")[0] : "/";
|
|
42
|
-
const decodedPath = decodeURIComponent(requestPath || "/");
|
|
43
|
-
const safePath = path_1.default.normalize(decodedPath).replace(/^(\.\.[/\\])+/, "");
|
|
44
|
-
const relativePath = safePath === "/" ? "/sentinel-report/index.html" : safePath;
|
|
45
|
-
const filePath = path_1.default.resolve(rootDir, `.${relativePath}`);
|
|
46
|
-
if (!filePath.startsWith(rootDir)) {
|
|
47
|
-
send(res, 403, "Forbidden");
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
let stat;
|
|
51
|
-
try {
|
|
52
|
-
stat = fs_1.default.statSync(filePath);
|
|
53
|
-
}
|
|
54
|
-
catch {
|
|
55
|
-
send(res, 404, "Not Found");
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
if (stat.isDirectory()) {
|
|
59
|
-
send(res, 404, "Not Found");
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
const extension = path_1.default.extname(filePath).toLowerCase();
|
|
63
|
-
res.writeHead(200, {
|
|
64
|
-
"Cache-Control": "no-store",
|
|
65
|
-
"Content-Length": stat.size,
|
|
66
|
-
"Content-Type": MIME_TYPES[extension] || "application/octet-stream"
|
|
67
|
-
});
|
|
68
|
-
fs_1.default.createReadStream(filePath).pipe(res);
|
|
69
|
-
});
|
|
70
|
-
server.listen(port, "127.0.0.1");
|