@@ -97,34 +97,36 @@ function baseTests(
97
97
98
98
it ( 'allows parsing of deeply nested new files' , ( ) => {
99
99
const PROJECT_DIR = setup ( tsConfigIncludeAll , false ) ;
100
+ const bazSlashBar = path . join ( 'baz' , 'bar' ) as 'baz/bar' ;
100
101
101
102
// parse once to: assert the config as correct, and to make sure the program is setup
102
103
expect ( ( ) => parseFile ( 'foo' , PROJECT_DIR ) ) . not . toThrow ( ) ;
103
104
// bar should throw because it doesn't exist yet
104
- expect ( ( ) => parseFile ( 'baz/bar' , PROJECT_DIR ) ) . toThrow ( ) ;
105
+ expect ( ( ) => parseFile ( bazSlashBar , PROJECT_DIR ) ) . toThrow ( ) ;
105
106
106
107
// write a new file and attempt to parse it
107
- writeFile ( PROJECT_DIR , 'baz/bar' ) ;
108
+ writeFile ( PROJECT_DIR , bazSlashBar ) ;
108
109
109
110
// both files should parse fine now
110
111
expect ( ( ) => parseFile ( 'foo' , PROJECT_DIR ) ) . not . toThrow ( ) ;
111
- expect ( ( ) => parseFile ( 'baz/bar' , PROJECT_DIR ) ) . not . toThrow ( ) ;
112
+ expect ( ( ) => parseFile ( bazSlashBar , PROJECT_DIR ) ) . not . toThrow ( ) ;
112
113
} ) ;
113
114
114
115
it ( 'allows renaming of files' , ( ) => {
115
116
const PROJECT_DIR = setup ( tsConfigIncludeAll , true ) ;
117
+ const bazSlashBar = path . join ( 'baz' , 'bar' ) as 'baz/bar' ;
116
118
117
119
// parse once to: assert the config as correct, and to make sure the program is setup
118
120
expect ( ( ) => parseFile ( 'foo' , PROJECT_DIR ) ) . not . toThrow ( ) ;
119
121
// bar should throw because it doesn't exist yet
120
- expect ( ( ) => parseFile ( 'baz/bar' , PROJECT_DIR ) ) . toThrow ( ) ;
122
+ expect ( ( ) => parseFile ( bazSlashBar , PROJECT_DIR ) ) . toThrow ( ) ;
121
123
122
124
// write a new file and attempt to parse it
123
- renameFile ( PROJECT_DIR , 'bar' , 'baz/bar' ) ;
125
+ renameFile ( PROJECT_DIR , 'bar' , bazSlashBar ) ;
124
126
125
127
// both files should parse fine now
126
128
expect ( ( ) => parseFile ( 'foo' , PROJECT_DIR ) ) . not . toThrow ( ) ;
127
- expect ( ( ) => parseFile ( 'baz/bar' , PROJECT_DIR ) ) . not . toThrow ( ) ;
129
+ expect ( ( ) => parseFile ( bazSlashBar , PROJECT_DIR ) ) . not . toThrow ( ) ;
128
130
} ) ;
129
131
130
132
it ( 'reacts to changes in the tsconfig' , ( ) => {
@@ -140,36 +142,6 @@ function baseTests(
140
142
expect ( ( ) => parseFile ( 'foo' , PROJECT_DIR ) ) . not . toThrow ( ) ;
141
143
expect ( ( ) => parseFile ( 'bar' , PROJECT_DIR ) ) . not . toThrow ( ) ;
142
144
} ) ;
143
-
144
- it ( 'handles tsconfigs with no includes/excludes (single level)' , ( ) => {
145
- const PROJECT_DIR = setup ( { } , false ) ;
146
-
147
- // parse once to: assert the config as correct, and to make sure the program is setup
148
- expect ( ( ) => parseFile ( 'foo' , PROJECT_DIR ) ) . not . toThrow ( ) ;
149
- expect ( ( ) => parseFile ( 'bar' , PROJECT_DIR ) ) . toThrow ( ) ;
150
-
151
- // write a new file and attempt to parse it
152
- writeFile ( PROJECT_DIR , 'bar' ) ;
153
-
154
- expect ( ( ) => parseFile ( 'foo' , PROJECT_DIR ) ) . not . toThrow ( ) ;
155
- expect ( ( ) => parseFile ( 'bar' , PROJECT_DIR ) ) . not . toThrow ( ) ;
156
- } ) ;
157
-
158
- it ( 'handles tsconfigs with no includes/excludes (nested)' , ( ) => {
159
- const PROJECT_DIR = setup ( { } , false ) ;
160
-
161
- // parse once to: assert the config as correct, and to make sure the program is setup
162
- expect ( ( ) => parseFile ( 'foo' , PROJECT_DIR ) ) . not . toThrow ( ) ;
163
- expect ( ( ) => parseFile ( 'baz/bar' , PROJECT_DIR ) ) . toThrow ( ) ;
164
-
165
- // write a new file and attempt to parse it
166
- writeFile ( PROJECT_DIR , 'baz/bar' ) ;
167
-
168
- expect ( ( ) => parseFile ( 'foo' , PROJECT_DIR ) ) . not . toThrow ( ) ;
169
- expect ( ( ) => parseFile ( 'baz/bar' , PROJECT_DIR ) ) . not . toThrow ( ) ;
170
- } ) ;
171
-
172
- // TODO - support the complex monorepo case with a tsconfig with no include/exclude
173
145
}
174
146
175
147
describe ( 'persistent parse' , ( ) => {
@@ -213,5 +185,49 @@ describe('persistent parse', () => {
213
185
const tsConfigIncludeAll = { } ;
214
186
215
187
baseTests ( tsConfigExcludeBar , tsConfigIncludeAll ) ;
188
+
189
+ it ( 'handles tsconfigs with no includes/excludes (single level)' , ( ) => {
190
+ const PROJECT_DIR = setup (
57AE
{ } , false ) ;
191
+
192
+ // parse once to: assert the config as correct, and to make sure the program is setup
193
+ expect ( ( ) => parseFile ( 'foo' , PROJECT_DIR ) ) . not . toThrow ( ) ;
194
+ expect ( ( ) => parseFile ( 'bar' , PROJECT_DIR ) ) . toThrow ( ) ;
195
+
196
+ // write a new file and attempt to parse it
197
+ writeFile ( PROJECT_DIR , 'bar' ) ;
198
+
199
+ expect ( ( ) => parseFile ( 'foo' , PROJECT_DIR ) ) . not . toThrow ( ) ;
200
+ expect ( ( ) => parseFile ( 'bar' , PROJECT_DIR ) ) . not . toThrow ( ) ;
201
+ } ) ;
202
+
203
+ it ( 'handles tsconfigs with no includes/excludes (nested)' , ( ) => {
204
+ const PROJECT_DIR = setup ( { } , false ) ;
205
+ const bazSlashBar = path . join ( 'baz' , 'bar' ) as 'baz/bar' ;
206
+
207
+ // parse once to: assert the config as correct, and to make sure the program is setup
208
+ expect ( ( ) => parseFile ( 'foo' , PROJECT_DIR ) ) . not . toThrow ( ) ;
209
+ expect ( ( ) => parseFile ( bazSlashBar , PROJECT_DIR ) ) . toThrow ( ) ;
210
+
211
+ // write a new file and attempt to parse it
212
+ writeFile ( PROJECT_DIR , bazSlashBar ) ;
213
+
214
+ expect ( ( ) => parseFile ( 'foo' , PROJECT_DIR ) ) . not . toThrow ( ) ;
215
+ expect ( ( ) => parseFile ( bazSlashBar , PROJECT_DIR ) ) . not . toThrow ( ) ;
216
+ } ) ;
217
+ } ) ;
218
+
219
+ /*
220
+ If there is no includes, then typescript will ask for a slightly different set of watchers.
221
+ */
222
+ describe ( 'tsconfig with overlapping globs' , ( ) => {
223
+ const tsConfigExcludeBar = {
224
+ include : [ './*' , './**/*' , './src/**/*' ] ,
225
+ exclude : [ './src/bar.ts' ] ,
226
+ } ;
227
+ const tsConfigIncludeAll = {
228
+ include : [ './*' , './**/*' , './src/**/*' ] ,
229
+ } ;
230
+
231
+ baseTests ( tsConfigExcludeBar , tsConfigIncludeAll ) ;
216
232
} ) ;
217
233
} ) ;
0 commit comments