File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change 1+ import { directoryExists } from '@form8ion/core' ;
12import { test as c8IsConfigured } from '@form8ion/c8' ;
23
34import nycIsConfigured from './nyc/tester.js' ;
45
56export 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}
Original file line number Diff line number Diff line change 1+ import { directoryExists } from '@form8ion/core' ;
12import { test as c8IsPresent } from '@form8ion/c8' ;
23
34import any from '@travi/any' ;
@@ -7,6 +8,7 @@ import {when} from 'vitest-when';
78import nycIsPresent from './nyc/tester.js' ;
89import coverageIsConfigured from './tester.js' ;
910
11+ vi . mock ( '@form8ion/core' ) ;
1012vi . mock ( '@form8ion/c8' ) ;
1113vi . 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 } ) ;
You can’t perform that action at this time.
0 commit comments