From 17e56231d2ba9b1ce355ee8988afd40c91bd47bf Mon Sep 17 00:00:00 2001 From: Markus Tacker Date: Tue, 20 Sep 2022 18:08:49 +0200 Subject: [PATCH] fix(runner): it should fail if not features are found --- runner/runSuite.spec.ts | 18 ++++++++++++++++++ runner/runSuite.ts | 14 ++++++++++++++ runner/test-data/runSuite/no-features/.gitkeep | 0 3 files changed, 32 insertions(+) create mode 100644 runner/test-data/runSuite/no-features/.gitkeep diff --git a/runner/runSuite.spec.ts b/runner/runSuite.spec.ts index 529c782..7e49dd7 100644 --- a/runner/runSuite.spec.ts +++ b/runner/runSuite.spec.ts @@ -57,4 +57,22 @@ describe('runSuite()', () => { assert.deepEqual(result.summary.skipped, 1) assert.deepEqual(result.summary.total, 2) }) + + it('should fail if the suite has not features', async () => { + const runner = runSuite( + await parseFeaturesInFolder( + path.join( + process.cwd(), + 'runner', + 'test-data', + 'runSuite', + 'no-features', + ), + ), + 'Example', + ) + + const result = await runner.run() + assert.equal(result.ok, false) + }) }) diff --git a/runner/runSuite.ts b/runner/runSuite.ts index 0b8cb01..391de1c 100644 --- a/runner/runSuite.ts +++ b/runner/runSuite.ts @@ -33,6 +33,20 @@ export const runSuite = >( return runner }, run: async (context?: Context) => { + if (featureFiles.length === 0) + return { + ok: false, + results: [], + summary: { + duration: 0, + failed: 0, + passed: 0, + skipped: 0, + total: 0, + }, + name, + } + const featureResults: [ParsedPath, FeatureResult][] = [] const featureNameResultMap: Record = {} diff --git a/runner/test-data/runSuite/no-features/.gitkeep b/runner/test-data/runSuite/no-features/.gitkeep new file mode 100644 index 0000000..e69de29