@@ -4,6 +4,7 @@ import { testSuite, expect } from 'manten';
4
4
import { createFixture } from 'fs-fixture' ;
5
5
import outdent from 'outdent' ;
6
6
import type { NodeApis } from '../utils/tsx.js' ;
7
+ import { hasCoverageSourcesContent } from '../utils/coverage-sources-content.js' ;
7
8
8
9
const cjsContextCheck = 'typeof module !== \'undefined\'' ;
9
10
const tsCheck = '1 as number' ;
@@ -352,7 +353,6 @@ export default testSuite(async ({ describe }, { tsx }: NodeApis) => {
352
353
describe ( packageType , ( { test, describe } ) => {
353
354
test ( 'from .js' , async ( { onTestFinish, onTestFail } ) => {
354
355
const fixture = await createFixture ( {
355
- ...files ,
356
356
'package.json' : JSON . stringify ( { type : packageType } ) ,
357
357
'import-from-js.js' : outdent `
358
358
import assert from 'assert';
@@ -459,7 +459,8 @@ export default testSuite(async ({ describe }, { tsx }: NodeApis) => {
459
459
// Could .js import TS files?
460
460
461
461
// Comment at EOF: could be a sourcemap declaration. Edge case for inserting functions here
462
- ` . trim ( ) ,
462
+ ` ,
463
+ ...files ,
463
464
} ) ;
464
465
onTestFinish ( async ( ) => await fixture . rm ( ) ) ;
465
466
@@ -488,7 +489,6 @@ export default testSuite(async ({ describe }, { tsx }: NodeApis) => {
488
489
489
490
describe ( 'from .ts' , async ( { test, onFinish } ) => {
490
491
const fixture = await createFixture ( {
491
- ...files ,
492
492
'package.json' : JSON . stringify ( { type : packageType } ) ,
493
493
494
494
'import-from-ts.ts' : ( { fixturePath } ) => outdent `
@@ -652,12 +652,18 @@ export default testSuite(async ({ describe }, { tsx }: NodeApis) => {
652
652
}));
653
653
654
654
// Comment at EOF: could be a sourcemap declaration. Edge case for inserting functions here
655
- ` . trim ( ) ,
655
+ ` ,
656
+ ...files ,
656
657
} ) ;
657
658
onFinish ( async ( ) => await fixture . rm ( ) ) ;
658
659
659
660
test ( 'import all' , async ( { onTestFail } ) => {
660
- const p = await tsx ( [ 'import-from-ts.ts' ] , fixture . path ) ;
661
+ const p = await tsx ( [ 'import-from-ts.ts' ] , {
662
+ cwd : fixture . path ,
663
+ env : {
664
+ NODE_V8_COVERAGE : 'coverage' ,
665
+ } ,
666
+ } ) ;
661
667
onTestFail ( ( error ) => {
662
668
console . error ( error ) ;
663
669
console . log ( p ) ;
@@ -678,6 +684,10 @@ export default testSuite(async ({ describe }, { tsx }: NodeApis) => {
678
684
// By "require()"ing an ESM file, it forces it to be compiled in a CJS context
679
685
expect ( p . stdout ) . toMatch ( `"mjs":{"mjsHasCjsContext":${ isCommonJs } }` ) ;
680
686
expect ( p . stderr ) . toBe ( '' ) ;
687
+
688
+ const coverageDirectory = fixture . getPath ( 'coverage' ) ;
689
+ const coverageSourceMapCache = await hasCoverageSourcesContent ( coverageDirectory ) ;
690
+ expect ( coverageSourceMapCache ) . toBe ( true ) ;
681
691
} ) ;
682
692
683
693
test ( 'tsconfig' , async ( { onTestFail } ) => {
0 commit comments