Skip to content

Commit 85017bc

Browse files
committed
feat(coverage): consider coverage detected if the coverage/ directory exists
1 parent 563f0a4 commit 85017bc

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/coverage/tester.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
import {directoryExists} from '@form8ion/core';
12
import {test as c8IsConfigured} from '@form8ion/c8';
23

34
import nycIsConfigured from './nyc/tester.js';
45

56
export default async function testCoverageBeingCollected({projectRoot}) {
67
const [c8Exists, nycExists] = await Promise.all([c8IsConfigured({projectRoot}), nycIsConfigured({projectRoot})]);
78

8-
return c8Exists || nycExists;
9+
return c8Exists || nycExists || directoryExists(`${projectRoot}/coverage`);
910
}

src/coverage/tester.test.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import {directoryExists} from '@form8ion/core';
12
import {test as c8IsPresent} from '@form8ion/c8';
23

34
import any from '@travi/any';
@@ -7,6 +8,7 @@ import {when} from 'vitest-when';
78
import nycIsPresent from './nyc/tester.js';
89
import coverageIsConfigured from './tester.js';
910

11+
vi.mock('@form8ion/core');
1012
vi.mock('@form8ion/c8');
1113
vi.mock('./nyc/tester.js');
1214

@@ -30,9 +32,18 @@ describe('coverage predicate', () => {
3032
expect(await coverageIsConfigured({projectRoot})).toBe(true);
3133
});
3234

35+
it('should return `true` if the `coverage/` directory exists', async () => {
36+
when(nycIsPresent).calledWith({projectRoot}).thenResolve(false);
37+
when(c8IsPresent).calledWith({projectRoot}).thenResolve(false);
38+
when(directoryExists).calledWith(`${projectRoot}/coverage`).thenResolve(true);
39+
40+
expect(await coverageIsConfigured({projectRoot})).toBe(true);
41+
});
42+
3343
it('should return `false` when neither c8 nor nyc are detected', async () => {
3444
when(nycIsPresent).calledWith({projectRoot}).thenResolve(false);
3545
when(c8IsPresent).calledWith({projectRoot}).thenResolve(false);
46+
when(directoryExists).calledWith(`${projectRoot}/coverage`).thenResolve(false);
3647

3748
expect(await coverageIsConfigured({projectRoot})).toBe(false);
3849
});

0 commit comments

Comments
 (0)