5
5
jsonToReadableText ,
6
6
} from "../helpers" ;
7
7
import {
8
- getSampleProjectConfigWithNodeNext ,
8
+ getProjectConfigWithNodeNext ,
9
+ } from "../helpers/contents" ;
10
+ import {
9
11
getSysForSampleProjectReferences ,
10
12
} from "../helpers/sampleProjectReferences" ;
11
13
import {
@@ -28,7 +30,7 @@ import {
28
30
} from "../helpers/virtualFileSystemWithWatch" ;
29
31
30
32
describe ( "unittests:: tsc-watch:: projects with references: invoking when references are already built" , ( ) => {
31
- function verify ( withNodeNext : boolean ) {
33
+ function verifySampleProject ( withNodeNext : boolean ) {
32
34
verifyTscWatch ( {
33
35
scenario : "projectsWithReferences" ,
34
36
subScenario : `on sample project${ withNodeNext ? " with nodenext" : "" } ` ,
@@ -66,7 +68,7 @@ describe("unittests:: tsc-watch:: projects with references: invoking when refere
66
68
"/user/username/projects/sample1/logic/tsconfig.json" ,
67
69
jsonToReadableText ( {
68
70
compilerOptions : {
69
- ...getSampleProjectConfigWithNodeNext ( withNodeNext ) ,
71
+ ...getProjectConfigWithNodeNext ( withNodeNext ) ,
70
72
composite : true ,
71
73
declaration : true ,
72
74
declarationDir : "decls" ,
@@ -83,86 +85,90 @@ describe("unittests:: tsc-watch:: projects with references: invoking when refere
83
85
baselineDependencies : true ,
84
86
} ) ;
85
87
}
86
- verify ( /*withNodeNext*/ false ) ;
87
- verify ( /*withNodeNext*/ true ) ;
88
+ verifySampleProject ( /*withNodeNext*/ false ) ;
89
+ verifySampleProject ( /*withNodeNext*/ true ) ;
88
90
89
91
function changeCompilerOpitonsPaths ( sys : TestServerHost , config : string , newPaths : object ) {
90
92
const configJson = JSON . parse ( sys . readFile ( config ) ! ) ;
91
93
configJson . compilerOptions . paths = newPaths ;
92
94
sys . writeFile ( config , jsonToReadableText ( configJson ) ) ;
93
95
}
94
96
95
- verifyTscWatch ( {
96
- scenario : "projectsWithReferences" ,
97
- subScenario : "on transitive references" ,
98
- sys : ( ) =>
99
- solutionBuildWithBaseline (
100
- createWatchedSystem (
101
- getFsContentsForTransitiveReferences ( ) ,
102
- { currentDirectory : `/user/username/projects/transitiveReferences` } ,
97
+ function verifyTransitiveReferences ( withNodeNext : boolean ) {
98
+ verifyTscWatch ( {
99
+ scenario : "projectsWithReferences" ,
100
+ subScenario : `on transitive references${ withNodeNext ? " with nodenext" : "" } ` ,
101
+ sys : ( ) =>
102
+ solutionBuildWithBaseline (
103
+ createWatchedSystem (
104
+ getFsContentsForTransitiveReferences ( withNodeNext ) ,
105
+ { currentDirectory : `/user/username/projects/transitiveReferences` } ,
106
+ ) ,
107
+ [ "tsconfig.c.json" ] ,
103
108
) ,
104
- [ "tsconfig.c.json" ] ,
105
- ) ,
106
- commandLineArgs : [ "-w" , "-p" , "tsconfig.c.json" , "--traceResolution" , "--explainFiles" ] ,
107
- edits : [
108
- {
109
- caption : "non local edit b ts, and build b" ,
110
- edit : sys => {
111
- sys . appendFile ( "b.ts" , `export function gfoo() { }` ) ;
112
- const solutionBuilder = createSolutionBuilder ( sys , [ "tsconfig.b.json" ] ) ;
113
- solutionBuilder . build ( ) ;
109
+ commandLineArgs : [ "-w" , "-p" , "tsconfig.c.json" , "--traceResolution" , "--explainFiles "] ,
110
+ edits : [
111
+ {
112
+ caption : "non local edit b ts, and build b" ,
113
+ edit : sys => {
114
+ sys . appendFile ( "b.ts" , `export function gfoo() { }` ) ;
115
+ const solutionBuilder = createSolutionBuilder ( sys , [ "tsconfig.b.json" ] ) ;
116
+ solutionBuilder . build ( ) ;
117
+ } ,
118
+ timeouts : sys => sys . runQueuedTimeoutCallbacks ( ) ,
114
119
} ,
115
- timeouts : sys => sys . runQueuedTimeoutCallbacks ( ) ,
116
- } ,
117
- {
118
- caption : "edit on config file" ,
119
- edit : sys => {
120
- sys . ensureFileOrFolder ( {
121
- path : "/user/username/projects/transitiveReferences/nrefs/a.d.ts" ,
122
- content : sys . readFile ( "/user/username/projects/transitiveReferences/refs/a.d.ts" ) ! ,
123
- } ) ;
124
- changeCompilerOpitonsPaths ( sys , "tsconfig.c.json" , { "@ref/*" : [ "./nrefs/*" ] } ) ;
120
+ {
121
+ caption : "edit on config file" ,
122
+ edit : sys => {
123
+ sys . ensureFileOrFolder ( {
124
+ path : "/user/username/projects/transitiveReferences/nrefs/a.d.ts" ,
125
+ content : sys . readFile ( "/user/username/projects/transitiveReferences/refs/a.d.ts" ) ! ,
126
+ } ) ;
127
+ changeCompilerOpitonsPaths ( sys , "tsconfig.c.json" , { "@ref/*" : [ "./nrefs/*" ] } ) ;
128
+ } ,
129
+ timeouts : sys => sys . runQueuedTimeoutCallbacks ( ) ,
125
130
} ,
126
- timeouts : sys => sys . runQueuedTimeoutCallbacks ( ) ,
127
- } ,
128
- {
129
- caption : "Revert config file edit" ,
130
- edit : sys => changeCompilerOpitonsPaths ( sys , "tsconfig.c.json" , { "@ref/*" : [ "./refs/*" ] } ) ,
131
- timeouts : sys => sys . runQueuedTimeoutCallbacks ( ) ,
132
- } ,
133
- {
134
- caption : "edit in referenced config file" ,
135
- edit : sys => changeCompilerOpitonsPaths ( sys , "tsconfig.b.json" , { "@ref/*" : [ "./nrefs/*" ] } ) ,
136
- timeouts : sys => sys . runQueuedTimeoutCallbacks ( ) ,
137
- } ,
138
- {
139
- caption : "Revert referenced config file edit" ,
140
- edit : sys => changeCompilerOpitonsPaths ( sys , "tsconfig.b.json" , { "@ref/*" : [ "./refs/*" ] } ) ,
141
- timeouts : sys => sys . runQueuedTimeoutCallbacks ( ) ,
142
- } ,
143
- {
144
- caption : "deleting referenced config file" ,
145
- edit : sys => sys . deleteFile ( "tsconfig.b.json" ) ,
146
- timeouts : sys => sys . runQueuedTimeoutCallbacks ( ) ,
147
- } ,
148
- {
149
- caption : "Revert deleting referenced config file" ,
150
- edit : sys => sys . writeFile ( "tsconfig.b.json" , getFsContentsForTransitiveReferencesBConfig ( ) ) ,
151
- timeouts : sys => sys . runQueuedTimeoutCallbacks ( ) ,
152
- } ,
153
- {
154
- caption : "deleting transitively referenced config file" ,
155
- edit : sys => sys . deleteFile ( "tsconfig.a.json" ) ,
156
- timeouts : sys => sys . runQueuedTimeoutCallbacks ( ) ,
157
- } ,
158
- {
159
- caption : "Revert deleting transitively referenced config file" ,
160
- edit : sys => sys . writeFile ( "tsconfig.a.json" , getFsContentsForTransitiveReferencesAConfig ( ) ) ,
161
- timeouts : sys => sys . runQueuedTimeoutCallbacks ( ) ,
162
- } ,
163
- ] ,
164
- baselineDependencies : true ,
165
- } ) ;
131
+ {
132
+ caption : "Revert config file edit" ,
133
+ edit : sys => changeCompilerOpitonsPaths ( sys , "tsconfig.c.json" , { "@ref/*" : [ "./refs/*" ] } ) ,
134
+ timeouts : sys => sys . runQueuedTimeoutCallbacks ( ) ,
135
+ } ,
136
+ {
137
+ caption : "edit in referenced config file" ,
138
+ edit : sys => changeCompilerOpitonsPaths ( sys , "tsconfig.b.json" , { "@ref/*" : [ "./nrefs/*" ] } ) ,
139
+ timeouts : sys => sys . runQueuedTimeoutCallbacks ( ) ,
140
+ } ,
141
+ {
142
+ caption : "Revert referenced config file edit" ,
143
+ edit : sys => changeCompilerOpitonsPaths ( sys , "tsconfig.b.json" , { "@ref/*" : [ "./refs/*" ] } ) ,
144
+ timeouts : sys => sys . runQueuedTimeoutCallbacks ( ) ,
145
+ } ,
146
+ {
147
+ caption : "deleting referenced config file" ,
148
+ edit : sys => sys . deleteFile ( "tsconfig.b.json" ) ,
149
+ timeouts : sys => sys . runQueuedTimeoutCallbacks ( ) ,
150
+ } ,
151
+ {
152
+ caption : "Revert deleting referenced config file" ,
153
+ edit : sys => sys . writeFile ( "tsconfig.b.json" , getFsContentsForTransitiveReferencesBConfig ( withNodeNext ) ) ,
154
+ timeouts : sys => sys . runQueuedTimeoutCallbacks ( ) ,
155
+ } ,
156
+ {
157
+ caption : "deleting transitively referenced config file" ,
158
+ edit : sys => sys . deleteFile ( "tsconfig.a.json" ) ,
159
+ timeouts : sys => sys . runQueuedTimeoutCallbacks ( ) ,
160
+ } ,
161
+ {
162
+ caption : "Revert deleting transitively referenced config file" ,
163
+ edit : sys => sys . writeFile ( "tsconfig.a.json" , getFsContentsForTransitiveReferencesAConfig ( withNodeNext ) ) ,
164
+ timeouts : sys => sys . runQueuedTimeoutCallbacks ( ) ,
165
+ } ,
166
+ ] ,
167
+ baselineDependencies : true ,
168
+ } ) ;
169
+ }
170
+ verifyTransitiveReferences ( /*withNodeNext*/ false ) ;
171
+ verifyTransitiveReferences ( /*withNodeNext*/ true ) ;
166
172
167
173
verifyTscWatch ( {
168
174
scenario : "projectsWithReferences" ,
0 commit comments