@sentinelqa/playwright-reporter 0.1.34 → 0.1.36

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 CHANGED
@@ -2,7 +2,6 @@
2
2
  const node_1 = require("@sentinelqa/uploader/node");
3
3
  const env_1 = require("./env");
4
4
  const quickDiagnosis_1 = require("./quickDiagnosis");
5
- const runHistory_1 = require("./runHistory");
6
5
  const { sentinelCaptureFailureContextFromReporter } = require("@sentinelqa/uploader/playwright");
7
6
  const colorize = (value, code) => {
8
7
  if (!process.stdout.isTTY)
@@ -46,7 +45,6 @@ class SentinelReporter {
46
45
  async onEnd() {
47
46
  const hasWorkspaceToken = Boolean(process.env.SENTINEL_TOKEN);
48
47
  const quickDiagnosis = (0, quickDiagnosis_1.buildQuickDiagnosis)(this.options.playwrightJsonPath);
49
- const runDiff = (0, runHistory_1.buildRunDiffSummary)(this.options.playwrightJsonPath);
50
48
  console.log("");
51
49
  if (quickDiagnosis?.lines.length) {
52
50
  console.log(yellow("Quick diagnosis"));
@@ -55,20 +53,13 @@ class SentinelReporter {
55
53
  }
56
54
  console.log("");
57
55
  }
58
- if (runDiff) {
59
- console.log(yellow("Run-to-run diff"));
60
- console.log(` ${dim(`New failures: ${runDiff.newFailures}`)}`);
61
- console.log(` ${dim(`Fixed since last run: ${runDiff.fixedTests}`)}`);
62
- console.log(` ${dim(`Still failing: ${runDiff.stillFailing}`)}`);
63
- console.log("");
64
- }
65
56
  if (hasWorkspaceToken) {
66
57
  console.log("");
67
58
  console.log(green("✔ Artifacts collected"));
68
- console.log("");
69
- console.log("Uploading hosted debugging report to Sentinel...");
70
- console.log("");
71
59
  }
60
+ console.log("");
61
+ console.log("Uploading hosted debugging report to Sentinel...");
62
+ console.log("");
72
63
  const upload = await (0, node_1.runSentinelUpload)({
73
64
  playwrightJsonPath: this.options.playwrightJsonPath,
74
65
  playwrightReportDir: this.options.playwrightReportDir,
@@ -54,6 +54,28 @@ const getPointerPaths = (branch) => [
54
54
  node_path_1.default.join(".sentinel", `latest-${branch}.json`),
55
55
  ...(branch === "main" ? [node_path_1.default.join(".sentinel", "latest-main.json")] : [])
56
56
  ];
57
+ const normalizeFailures = (snapshot) => {
58
+ if (!snapshot)
59
+ return [];
60
+ if (Array.isArray(snapshot.failures)) {
61
+ return snapshot.failures.filter((failure) => Boolean(failure &&
62
+ typeof failure.id === "string" &&
63
+ typeof failure.matchKey === "string" &&
64
+ typeof failure.title === "string" &&
65
+ typeof failure.status === "string"));
66
+ }
67
+ if (Array.isArray(snapshot.tests)) {
68
+ return snapshot.tests
69
+ .filter((test) => test && typeof test.id === "string")
70
+ .map((test) => ({
71
+ id: test.id,
72
+ matchKey: typeof test.matchKey === "string" ? test.matchKey : test.id,
73
+ title: typeof test.title === "string" ? test.title : test.id,
74
+ status: typeof test.status === "string" ? test.status : "failed"
75
+ }));
76
+ }
77
+ return [];
78
+ };
57
79
  const readSnapshot = (filePath) => {
58
80
  if (!node_fs_1.default.existsSync(filePath))
59
81
  return null;
@@ -78,13 +100,14 @@ const buildRunDiffSummary = (playwrightJsonPath) => {
78
100
  const snapshot = buildSnapshot(playwrightJsonPath);
79
101
  const previous = readSnapshot(node_path_1.default.resolve(process.cwd(), ".sentinel", `latest-${snapshot.branch}.json`)) ||
80
102
  readSnapshot(node_path_1.default.resolve(process.cwd(), ".sentinel", "latest.json"));
103
+ const previousFailures = normalizeFailures(previous);
81
104
  const currentFailureIds = new Set(snapshot.failures.map((test) => test.id));
82
105
  const currentFailureMatchKeys = new Set(snapshot.failures.map((test) => test.matchKey));
83
106
  const diff = previous && previous.generatedAt !== snapshot.generatedAt
84
107
  ? {
85
- newFailures: snapshot.failures.filter((test) => !previous.failures.some((prev) => prev.id === test.id || prev.matchKey === test.matchKey)).length,
86
- fixedTests: previous.failures.filter((test) => !currentFailureIds.has(test.id) && !currentFailureMatchKeys.has(test.matchKey)).length,
87
- stillFailing: snapshot.failures.filter((test) => previous.failures.some((prev) => prev.id === test.id || prev.matchKey === test.matchKey)).length
108
+ newFailures: snapshot.failures.filter((test) => !previousFailures.some((prev) => prev.id === test.id || prev.matchKey === test.matchKey)).length,
109
+ fixedTests: previousFailures.filter((test) => !currentFailureIds.has(test.id) && !currentFailureMatchKeys.has(test.matchKey)).length,
110
+ stillFailing: snapshot.failures.filter((test) => previousFailures.some((prev) => prev.id === test.id || prev.matchKey === test.matchKey)).length
88
111
  }
89
112
  : null;
90
113
  writeSnapshot(snapshot);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentinelqa/playwright-reporter",
3
- "version": "0.1.34",
3
+ "version": "0.1.36",
4
4
  "private": false,
5
5
  "description": "Playwright reporter for CI debugging with optional Sentinel cloud dashboards",
6
6
  "license": "MIT",