@@ -3,12 +3,13 @@ import { basename, join, normalize } from 'path'
33
44import { DiagnosticCategory , EmitOutput , ModuleKind , ScriptTarget , TranspileOutput } from 'typescript'
55
6- import { makeCompiler } from '../__helpers__/fakers'
6+ import { createConfigSet , makeCompiler } from '../__helpers__/fakers'
77import { mockFolder } from '../__helpers__/path'
88import type { DepGraphInfo } from '../types'
99import { Errors , interpolate } from '../utils/messages'
1010
1111import { updateOutput } from './compiler-utils'
12+ import { TsCompiler } from './ts-compiler'
1213
1314const baseTsJestConfig = { tsconfig : join ( process . cwd ( ) , 'tsconfig.spec.json' ) }
1415
@@ -163,9 +164,12 @@ describe('TsCompiler', () => {
163164 const sourceMap = '{}'
164165
165166 test . each ( [ true , false ] ) ( 'should compile codes with useESM %p' , ( useESM ) => {
166- const compiler = makeCompiler ( {
167+ const configSet = createConfigSet ( {
167168 tsJestConfig : { ...baseTsJestConfig , useESM } ,
168169 } )
170+ const emptyFile = join ( mockFolder , 'empty.ts' )
171+ configSet . parsedTsConfig . fileNames . push ( emptyFile )
172+ const compiler = new TsCompiler ( configSet , new Map ( ) )
169173 // @ts -expect-error testing purpose
170174 compiler . _languageService . getEmitOutput = jest . fn ( ) . mockReturnValueOnce ( {
171175 outputFiles : [ { text : sourceMap } , { text : jsOutput } ] ,
@@ -193,6 +197,13 @@ describe('TsCompiler', () => {
193197 expect ( esModuleInterop ) . toEqual ( useESM ? true : esModuleInterop )
194198 expect ( allowSyntheticDefaultImports ) . toEqual ( useESM ? true : allowSyntheticDefaultImports )
195199 expect ( output ) . toEqual ( updateOutput ( jsOutput , fileName , sourceMap ) )
200+
201+ // @ts -expect-error testing purpose
202+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
203+ compiler . _languageService ! . getSemanticDiagnostics ( fileName )
204+
205+ // @ts -expect-error testing purpose
206+ expect ( compiler . _fileContentCache . has ( emptyFile ) ) . toBe ( true )
196207 } )
197208
198209 test ( 'should show a warning message and return original file content for non ts/tsx files if emitSkipped is true' , ( ) => {
0 commit comments