@@ -186,11 +186,21 @@ describe('TestPathPatternsExecutor', () => {
186
186
} ) ;
187
187
188
188
it ( 'returns true only if matches relative path' , ( ) => {
189
+ const rootDir = '/home/myuser/' ;
190
+
189
191
const testPathPatterns = makeExecutor ( [ 'home' ] , {
190
- rootDir : '/home/myuser/' ,
192
+ rootDir,
191
193
} ) ;
192
- expect ( testPathPatterns . isMatch ( '/home/myuser/LoginPage.js' ) ) . toBe ( false ) ;
193
- expect ( testPathPatterns . isMatch ( '/home/myuser/HomePage.js' ) ) . toBe ( true ) ;
194
+ expect (
195
+ testPathPatterns . isMatch (
196
+ path . relative ( rootDir , '/home/myuser/LoginPage.js' ) ,
197
+ ) ,
198
+ ) . toBe ( false ) ;
199
+ expect (
200
+ testPathPatterns . isMatch (
201
+ path . relative ( rootDir , '/home/myuser/HomePage.js' ) ,
202
+ ) ,
203
+ ) . toBe ( true ) ;
194
204
} ) ;
195
205
196
206
it ( 'matches absolute paths regardless of rootDir' , ( ) => {
@@ -230,5 +240,20 @@ describe('TestPathPatternsExecutor', () => {
230
240
const testPathPatterns = makeExecutor ( [ 'a/b' ] , config ) ;
231
241
expect ( testPathPatterns . isMatch ( 'C:\\foo\\a\\b' ) ) . toBe ( true ) ;
232
242
} ) ;
243
+
244
+ it ( 'matches absolute path with absPath' , ( ) => {
245
+ const pattern = '^/home/app/' ;
246
+ const rootDir = '/home/app' ;
247
+ const absolutePath = '/home/app/packages/' ;
248
+
249
+ const testPathPatterns = makeExecutor ( [ pattern ] , {
250
+ rootDir,
251
+ } ) ;
252
+
253
+ const relativePath = path . relative ( rootDir , absolutePath ) ;
254
+
255
+ expect ( testPathPatterns . isMatch ( relativePath ) ) . toBe ( false ) ;
256
+ expect ( testPathPatterns . isMatch ( absolutePath ) ) . toBe ( true ) ;
257
+ } ) ;
233
258
} ) ;
234
259
} ) ;
0 commit comments