@@ -3,26 +3,23 @@ import { describe, expect } from 'vitest';
33import { loadTargetConfig } from './utils.js' ;
44
55describe ( 'loadTargetConfig' , ( ) => {
6- const parseConfigFileTextToJsonSpy = vi . spyOn (
7- tsModule ,
8- 'parseConfigFileTextToJson' ,
9- ) ;
6+ const readConfigFileSpy = vi . spyOn ( tsModule , 'readConfigFile' ) ;
107 const parseJsonConfigFileContentSpy = vi . spyOn (
118 tsModule ,
129 'parseJsonConfigFileContent' ,
1310 ) ;
1411
15- it ( 'should return the parsed content of a tsconfig file and ist TypeScript helper to parse it' , async ( ) => {
16- await expect (
12+ it ( 'should return the parsed content of a tsconfig file and ist TypeScript helper to parse it' , ( ) => {
13+ expect (
1714 loadTargetConfig (
1815 'packages/plugin-typescript/mocks/fixtures/basic-setup/tsconfig.init.json' ,
1916 ) ,
20- ) . resolves . toStrictEqual (
17+ ) . toStrictEqual (
2118 expect . objectContaining ( {
2219 fileNames : expect . any ( Array ) ,
2320 options : {
2421 module : 1 ,
25- configFilePath : undefined ,
22+ configFilePath : expect . stringContaining ( 'tsconfig.init.json' ) ,
2623 esModuleInterop : true ,
2724 forceConsistentCasingInFileNames : true ,
2825 skipLibCheck : true ,
@@ -31,25 +28,40 @@ describe('loadTargetConfig', () => {
3128 } ,
3229 } ) ,
3330 ) ;
34- expect ( parseConfigFileTextToJsonSpy ) . toHaveBeenCalledTimes ( 1 ) ;
35- expect ( parseConfigFileTextToJsonSpy ) . toHaveBeenCalledWith (
36- 'packages/plugin-typescript/mocks/fixtures/basic-setup/ tsconfig.init.json',
37- expect . stringContaining ( '/* Projects */' ) ,
31+ expect ( readConfigFileSpy ) . toHaveBeenCalledTimes ( 1 ) ;
32+ expect ( readConfigFileSpy ) . toHaveBeenCalledWith (
33+ expect . stringContaining ( ' tsconfig.init.json') ,
34+ expect . any ( Function ) ,
3835 ) ;
3936 expect ( parseJsonConfigFileContentSpy ) . toHaveBeenCalledTimes ( 1 ) ;
40- expect ( parseJsonConfigFileContentSpy ) . toHaveBeenCalledWith (
37+ // parseJsonConfigFileContent is called with complex internal objects
38+ } ) ;
39+
40+ it ( 'should return the parsed content of a tsconfig file that extends another config' , ( ) => {
41+ expect (
42+ loadTargetConfig (
43+ 'packages/plugin-typescript/mocks/fixtures/basic-setup/tsconfig.extends-extending.json' ,
44+ ) ,
45+ ) . toStrictEqual (
4146 expect . objectContaining ( {
42- compilerOptions : expect . objectContaining ( {
43- esModuleInterop : true ,
44- forceConsistentCasingInFileNames : true ,
45- module : 'commonjs' ,
46- skipLibCheck : true ,
47- strict : true ,
48- target : 'es2016' ,
47+ fileNames : expect . arrayContaining ( [
48+ // from tsconfig.extends-base.json#includes and tsconfig.extends-extending.json#excludes
49+ expect . stringContaining ( 'src/0-no-diagnostics/' ) ,
50+ ] ) ,
51+ options : expect . objectContaining ( {
52+ // Options from tsconfig.extends-base.json
53+ rootDir : expect . stringContaining ( 'src' ) ,
54+ // Options from tsconfig.extends-extending.json
55+ module : 1 ,
56+ configFilePath : expect . stringContaining (
57+ 'tsconfig.extends-extending.json' ,
58+ ) ,
59+ verbatimModuleSyntax : true , // Overrides base config's false
4960 } ) ,
5061 } ) ,
51- expect . any ( Object ) ,
52- expect . any ( String ) ,
5362 ) ;
63+
64+ expect ( readConfigFileSpy ) . toHaveBeenCalledTimes ( 1 ) ;
65+ expect ( parseJsonConfigFileContentSpy ) . toHaveBeenCalledTimes ( 1 ) ;
5466 } ) ;
5567} ) ;
0 commit comments