Skip to content

Commit 1be99d7

Browse files
author
Alex Plischke
authored
feat: include skipped tests in report (#49)
1 parent 0ce70ca commit 1be99d7

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

src/code.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ import { TestCase } from '@playwright/test/reporter';
88
* NOTE: This does not return the entire body of a TestCase, only the TestSteps
99
*/
1010
export function getLines(testCase: TestCase) {
11+
if (testCase.results.length === 0) {
12+
return [];
13+
}
14+
1115
const result = testCase.results[testCase.results.length - 1];
1216
const stepLines = result.steps
1317
.map((step) => step.location?.line)

src/reporter.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -361,12 +361,25 @@ export default class SauceReporter implements Reporter {
361361
const assets: Asset[] = [];
362362

363363
for (const testCase of rootSuite.tests) {
364-
const lastResult = testCase.results[testCase.results.length - 1];
364+
let lastResult = testCase.results[testCase.results.length - 1];
365365

366-
// TestCase can have 0 results if it was skipped with the skip annotation or
367-
// if it was filtered with the grep cli flag
366+
// TestCase can have 0 results if it was skipped with the skip annotation,
367+
// filtered with the grep cli flag or never executed due to early
368+
// termination, such as the fail-fast option `maxFailures`.
368369
if (!lastResult) {
369-
break;
370+
lastResult = {
371+
duration: 0,
372+
errors: [],
373+
parallelIndex: 0,
374+
retry: 0,
375+
startTime: this.startedAt || new Date(),
376+
status: 'skipped',
377+
stderr: [],
378+
stdout: [],
379+
steps: [],
380+
workerIndex: 0,
381+
attachments: [],
382+
};
370383
}
371384

372385
const lines = getLines(testCase);

0 commit comments

Comments
 (0)