From 6fe1b1aaf68f99d45ee79817a6128f2ae303b6a3 Mon Sep 17 00:00:00 2001 From: Derk-Jan Karrenbeld Date: Wed, 31 Jul 2024 22:41:38 +0200 Subject: [PATCH] Support for skipping only when the exercise allows it --- src/output.ts | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/output.ts b/src/output.ts index cd6ebcc..e258fec 100644 --- a/src/output.ts +++ b/src/output.ts @@ -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 } } @@ -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' @@ -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<