@piwitests/reporter 0.31.0 → 0.33.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.
Files changed (2) hide show
  1. package/dist/index.js +20 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2666,10 +2666,24 @@ function mergeAnnotations(test, result) {
2666
2666
  }
2667
2667
  return out;
2668
2668
  }
2669
+ function expectsFailure(annotations) {
2670
+ if (annotations.some((a) => a.type === "skip" || a.type === "fixme")) return false;
2671
+ return annotations.some((a) => a.type === "fail");
2672
+ }
2673
+ var EXPECTED_FAILURE_PASSED_MESSAGE = "Expected to fail, but passed.";
2674
+ function expectedFailureError(rawStatus, annotations) {
2675
+ return rawStatus === "passed" && expectsFailure(annotations) ? EXPECTED_FAILURE_PASSED_MESSAGE : null;
2676
+ }
2669
2677
  function classifyStatus(rawStatus, annotations) {
2670
- if (rawStatus !== "skipped") return rawStatus;
2671
- const intentional = annotations.some((a) => a.type === "skip" || a.type === "fixme");
2672
- return intentional ? "skipped" : "didnotrun";
2678
+ if (rawStatus === "skipped") {
2679
+ const intentional = annotations.some((a) => a.type === "skip" || a.type === "fixme");
2680
+ return intentional ? "skipped" : "didnotrun";
2681
+ }
2682
+ if (expectsFailure(annotations)) {
2683
+ if (rawStatus === "failed") return "passed";
2684
+ if (rawStatus === "passed") return "failed";
2685
+ }
2686
+ return rawStatus;
2673
2687
  }
2674
2688
  function resolveUnrunReason(runStatus, opts) {
2675
2689
  if (runStatus === "timedout") return "global-timeout";
@@ -4240,7 +4254,9 @@ var PiwiDashboardReporter = class _PiwiDashboardReporter {
4240
4254
  // Effective per-test timeout (reflects project config + describe-level
4241
4255
  // overrides). `0` means unbounded; kept as-is so the dashboard can flag it.
4242
4256
  timeout: test.timeout ?? null,
4243
- error: buildErrorText(result),
4257
+ // A `test.fail()` test that passed is now `failed` with no recorded error;
4258
+ // Playwright reports the same line, so synthesize it.
4259
+ error: expectedFailureError(result.status, annotations) ?? buildErrorText(result),
4244
4260
  retries: result.retry,
4245
4261
  attempts: attempts.map((a) => ({ ...a })),
4246
4262
  workerIndex: workerIndexOf(result),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@piwitests/reporter",
3
- "version": "0.31.0",
3
+ "version": "0.33.0",
4
4
  "description": "Playwright reporter that streams results, traces and HTML reports to a Piwi Dashboard instance",
5
5
  "url": "https://github.com/PiwiTests/platform",
6
6
  "homepage": "https://piwitests.dev",