Skip to content

Commit

Permalink
Support for skipping only when the exercise allows it
Browse files Browse the repository at this point in the history
  • Loading branch information
SleeplessByte committed Jul 31, 2024
1 parent 72edf5d commit 6fe1b1a
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions src/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ type ExerciseConfig = {
'flag.tests.task-per-describe': boolean
'flag.tests.may-run-long': boolean
'flag.tests.includes-optional': boolean
'flag.tests.jest'?: boolean
'flag.tests.tstyche'?: boolean
}
}

Expand Down Expand Up @@ -66,11 +68,9 @@ export class Output {
this.results.status =
aggregatedResults.numRuntimeErrorTestSuites === 0 &&
aggregatedResults.numFailedTestSuites === 0 &&
// Pending tests are skipped tests. test.skip tests are fine in our
// reporter and should not be forced to have ran here. So the next
// line is commented out.
// Pending tests are skipped tests. test.skip tests are fine if the
// exercise reports that there are optional tests.
//
// aggregatedResults.numPendingTests === 0 &&
aggregatedResults.numFailedTests === 0
? 'pass'
: 'fail'
Expand All @@ -88,6 +88,24 @@ export class Output {
'an issue if the problem persists.'
)
}

if (
this.results.status === 'pass' &&
(aggregatedResults.numPendingTests !== 0 ||
aggregatedResults.numPendingTestSuites !== 0)
) {
if (
!this.configFlag('flag.tests.includes-optional') &&
this.config?.custom
) {
this.results.status = 'fail'
this.error(
'Expected to see 0 skipped tests and 0 skipped test suites. ' +
'None of the tests in this exercise are optional. The skipped ' +
'tests will not show up, but were found during the last run.'
)
}
}
}

const parsedSources: Record<
Expand Down

0 comments on commit 6fe1b1a

Please sign in to comment.