@arghajit/dummy 0.1.0-beta-3 → 0.1.0-beta-5
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.
|
@@ -16,7 +16,7 @@ export declare class PlaywrightPulseReporter implements Reporter {
|
|
|
16
16
|
onBegin(config: FullConfig, suite: Suite): void;
|
|
17
17
|
onTestBegin(test: TestCase): void;
|
|
18
18
|
private processStep;
|
|
19
|
-
getBrowserInfo(test: TestCase):
|
|
19
|
+
getBrowserInfo(test: TestCase): string;
|
|
20
20
|
onTestEnd(test: TestCase, result: PwTestResult): Promise<void>;
|
|
21
21
|
onError(error: any): void;
|
|
22
22
|
private _writeShardResults;
|
|
@@ -146,40 +146,113 @@ class PlaywrightPulseReporter {
|
|
|
146
146
|
steps: [],
|
|
147
147
|
};
|
|
148
148
|
}
|
|
149
|
-
|
|
150
|
-
var _a, _b, _c;
|
|
149
|
+
getBrowserInfo(test) {
|
|
150
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
151
|
+
// Changed return type to string
|
|
151
152
|
const project = (_a = test.parent) === null || _a === void 0 ? void 0 : _a.project();
|
|
152
|
-
const
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
153
|
+
const configuredBrowserType = (_c = (_b = project === null || project === void 0 ? void 0 : project.use) === null || _b === void 0 ? void 0 : _b.defaultBrowserType) === null || _c === void 0 ? void 0 : _c.toLowerCase(); // e.g., "chromium", "firefox", "webkit"
|
|
154
|
+
const userAgentString = (_d = project === null || project === void 0 ? void 0 : project.use) === null || _d === void 0 ? void 0 : _d.userAgent;
|
|
155
|
+
let finalBrowserName = configuredBrowserType || "unknown"; // Start with the configured type or "unknown"
|
|
156
|
+
let version = "";
|
|
157
|
+
let osName = "";
|
|
158
|
+
let osVersion = "";
|
|
159
|
+
let deviceType = "";
|
|
160
|
+
if (userAgentString) {
|
|
161
|
+
try {
|
|
162
|
+
const parser = new ua_parser_js_1.UAParser(userAgentString);
|
|
163
|
+
const uaResult = parser.getResult();
|
|
164
|
+
deviceType = uaResult.device.type || ""; // e.g., "mobile", "tablet", "console", "smarttv"
|
|
165
|
+
// 1. Try UAParser's browser name
|
|
166
|
+
if (uaResult.browser.name) {
|
|
167
|
+
finalBrowserName = uaResult.browser.name;
|
|
168
|
+
if (uaResult.browser.version) {
|
|
169
|
+
// Get major version, or full version if no dot
|
|
170
|
+
version = ` v${uaResult.browser.version.split(".")[0]}`;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
// If UAParser didn't find a browser name, but we have an engine,
|
|
174
|
+
// it might be more informative than just the configuredBrowserType.
|
|
175
|
+
else if (uaResult.engine.name &&
|
|
176
|
+
configuredBrowserType !== uaResult.engine.name.toLowerCase()) {
|
|
177
|
+
// Prefer engine name if it's more specific and different from default (e.g. WebKit for a generic device)
|
|
178
|
+
finalBrowserName = uaResult.engine.name;
|
|
179
|
+
}
|
|
180
|
+
// 2. Specific Overrides / Refinements
|
|
181
|
+
// Handling for mobile devices, especially if UAParser provides generic browser names
|
|
182
|
+
if (deviceType === "mobile" || deviceType === "tablet") {
|
|
183
|
+
if (((_e = uaResult.os.name) === null || _e === void 0 ? void 0 : _e.toLowerCase().includes("ios")) ||
|
|
184
|
+
uaResult.browser.name === "Mobile Safari") {
|
|
185
|
+
finalBrowserName = "Mobile Safari";
|
|
186
|
+
}
|
|
187
|
+
else if ((_f = uaResult.os.name) === null || _f === void 0 ? void 0 : _f.toLowerCase().includes("android")) {
|
|
188
|
+
if ((_g = uaResult.browser.name) === null || _g === void 0 ? void 0 : _g.toLowerCase().includes("chrome")) {
|
|
189
|
+
finalBrowserName = "Chrome Mobile";
|
|
190
|
+
}
|
|
191
|
+
else if ((_h = uaResult.browser.name) === null || _h === void 0 ? void 0 : _h.toLowerCase().includes("firefox")) {
|
|
192
|
+
finalBrowserName = "Firefox Mobile";
|
|
193
|
+
}
|
|
194
|
+
else if (uaResult.engine.name === "Blink" &&
|
|
195
|
+
!uaResult.browser.name) {
|
|
196
|
+
// Generic Android Webview
|
|
197
|
+
finalBrowserName = "Android WebView";
|
|
198
|
+
}
|
|
199
|
+
else if (uaResult.browser.name) {
|
|
200
|
+
finalBrowserName = `${uaResult.browser.name} Mobile`; // Generic, e.g., "Opera Mobile"
|
|
201
|
+
}
|
|
202
|
+
else {
|
|
203
|
+
finalBrowserName = "Android Browser"; // Fallback for Android
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
else if (uaResult.browser.name === "Electron") {
|
|
208
|
+
finalBrowserName = "Electron App"; // More descriptive for Electron
|
|
209
|
+
// For Electron, version might be app's version, not Chromium's.
|
|
210
|
+
// You might need custom logic if you want the underlying Chromium version.
|
|
211
|
+
}
|
|
212
|
+
// 3. OS Information
|
|
213
|
+
if (uaResult.os.name) {
|
|
214
|
+
osName = ` on ${uaResult.os.name}`;
|
|
215
|
+
if (uaResult.os.version) {
|
|
216
|
+
osVersion = ` ${uaResult.os.version.split(".")[0]}`; // Major OS version
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
catch (error) {
|
|
221
|
+
console.warn(`Pulse Reporter: Error parsing User-Agent string "${userAgentString}":`, error);
|
|
222
|
+
// Fallback to configuredBrowserType already set in finalBrowserName
|
|
163
223
|
}
|
|
164
|
-
// 3. Clean version string
|
|
165
|
-
const version = result.browser.version
|
|
166
|
-
? ` v${result.browser.version.split(".")[0]}`
|
|
167
|
-
: "";
|
|
168
|
-
// 4. OS information
|
|
169
|
-
const osInfo = result.os.name ? ` on ${result.os.name}` : "";
|
|
170
|
-
const osVersion = result.os.version
|
|
171
|
-
? ` ${result.os.version.split(".")[0]}`
|
|
172
|
-
: "";
|
|
173
|
-
return `${browser}${version}${osInfo}${osVersion}`.trim();
|
|
174
224
|
}
|
|
175
|
-
|
|
176
|
-
|
|
225
|
+
// If after UA parsing, we still have a generic engine name like "Blink" or "WebKit"
|
|
226
|
+
// and a more specific configuredBrowserType exists (like "chromium"), prefer the configured one.
|
|
227
|
+
if ((finalBrowserName.toLowerCase() === "blink" ||
|
|
228
|
+
finalBrowserName.toLowerCase() === "webkit" ||
|
|
229
|
+
finalBrowserName.toLowerCase() === "gecko") &&
|
|
230
|
+
configuredBrowserType &&
|
|
231
|
+
configuredBrowserType !== "unknown") {
|
|
232
|
+
finalBrowserName =
|
|
233
|
+
configuredBrowserType.charAt(0).toUpperCase() +
|
|
234
|
+
configuredBrowserType.slice(1); // Capitalize
|
|
235
|
+
}
|
|
236
|
+
// Construct the display string
|
|
237
|
+
// Prioritize showing device type for mobile/tablet if it adds clarity
|
|
238
|
+
let displayString = finalBrowserName;
|
|
239
|
+
if (version)
|
|
240
|
+
displayString += version;
|
|
241
|
+
// Add device type if it's mobile/tablet and not already obvious from browser name
|
|
242
|
+
if ((deviceType === "mobile" || deviceType === "tablet") &&
|
|
243
|
+
!finalBrowserName.toLowerCase().includes(deviceType)) {
|
|
244
|
+
// displayString += ` (${deviceType.charAt(0).toUpperCase() + deviceType.slice(1)})`;
|
|
177
245
|
}
|
|
246
|
+
if (osName)
|
|
247
|
+
displayString += osName;
|
|
248
|
+
if (osVersion && osName)
|
|
249
|
+
displayString += osVersion; // Only add osVersion if osName is present
|
|
250
|
+
return displayString.trim();
|
|
178
251
|
}
|
|
179
252
|
async onTestEnd(test, result) {
|
|
180
253
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
181
254
|
const project = (_a = test.parent) === null || _a === void 0 ? void 0 : _a.project();
|
|
182
|
-
const
|
|
255
|
+
const browserDisplayInfo = this.getBrowserInfo(test);
|
|
183
256
|
const testStatus = convertStatus(result.status, test);
|
|
184
257
|
const startTime = new Date(result.startTime);
|
|
185
258
|
const endTime = new Date(startTime.getTime() + result.duration);
|
|
@@ -191,7 +264,7 @@ class PlaywrightPulseReporter {
|
|
|
191
264
|
const processAllSteps = async (steps) => {
|
|
192
265
|
let processed = [];
|
|
193
266
|
for (const step of steps) {
|
|
194
|
-
const processedStep = await this.processStep(step, testIdForFiles,
|
|
267
|
+
const processedStep = await this.processStep(step, testIdForFiles, browserDisplayInfo, test);
|
|
195
268
|
processed.push(processedStep);
|
|
196
269
|
if (step.steps && step.steps.length > 0) {
|
|
197
270
|
processedStep.steps = await processAllSteps(step.steps);
|
|
@@ -231,7 +304,7 @@ class PlaywrightPulseReporter {
|
|
|
231
304
|
duration: result.duration,
|
|
232
305
|
startTime: startTime,
|
|
233
306
|
endTime: endTime,
|
|
234
|
-
browser:
|
|
307
|
+
browser: browserDisplayInfo,
|
|
235
308
|
retries: result.retry,
|
|
236
309
|
steps: ((_f = result.steps) === null || _f === void 0 ? void 0 : _f.length) ? await processAllSteps(result.steps) : [],
|
|
237
310
|
errorMessage: (_g = result.error) === null || _g === void 0 ? void 0 : _g.message,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arghajit/dummy",
|
|
3
3
|
"author": "Arghajit Singha",
|
|
4
|
-
"version": "0.1.0-beta-
|
|
4
|
+
"version": "0.1.0-beta-5",
|
|
5
5
|
"description": "A Playwright reporter and dashboard for visualizing test results.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"playwright",
|
|
@@ -62,6 +62,7 @@
|
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"@types/node": "^20",
|
|
65
|
+
"@types/ua-parser-js": "^0.7.39",
|
|
65
66
|
"eslint": "9.25.1",
|
|
66
67
|
"typescript": "^5"
|
|
67
68
|
},
|