@@ -3,26 +3,23 @@ import { describe, expect } from 'vitest';
3
3
import { loadTargetConfig } from './utils.js' ;
4
4
5
5
describe ( 'loadTargetConfig' , ( ) => {
6
- const parseConfigFileTextToJsonSpy = vi . spyOn (
7
- tsModule ,
8
- 'parseConfigFileTextToJson' ,
9
- ) ;
6
+ const readConfigFileSpy = vi . spyOn ( tsModule , 'readConfigFile' ) ;
10
7
const parseJsonConfigFileContentSpy = vi . spyOn (
11
8
tsModule ,
12
9
'parseJsonConfigFileContent' ,
13
10
) ;
14
11
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 (
17
14
loadTargetConfig (
18
15
'packages/plugin-typescript/mocks/fixtures/basic-setup/tsconfig.init.json' ,
19
16
) ,
20
- ) . resolves . toStrictEqual (
17
+ ) . toStrictEqual (
21
18
expect . objectContaining ( {
22
19
fileNames : expect . any ( Array ) ,
23
20
options : {
24
21
module : 1 ,
25
- configFilePath : undefined ,
22
+ configFilePath : expect . stringContaining ( 'tsconfig.init.json' ) ,
26
23
esModuleInterop : true ,
27
24
forceConsistentCasingInFileNames : true ,
28
25
skipLibCheck : true ,
@@ -31,25 +28,40 @@ describe('loadTargetConfig', () => {
31
28
} ,
32
29
} ) ,
33
30
) ;
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 ) ,
38
35
) ;
39
36
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 (
41
46
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
49
60
} ) ,
50
61
} ) ,
51
- expect . any ( Object ) ,
52
- expect . any ( String ) ,
53
62
) ;
63
+
64
+ expect ( readConfigFileSpy ) . toHaveBeenCalledTimes ( 1 ) ;
65
+ expect ( parseJsonConfigFileContentSpy ) . toHaveBeenCalledTimes ( 1 ) ;
54
66
} ) ;
55
67
} ) ;
0 commit comments