Skip to content

Commit a7d7b54

Browse files
author
Jørgen Sverre Lien Sellæg
committed
update ignoredFiles test to use anymatch as it does in webpack as well
1 parent 8ae1349 commit a7d7b54

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

packages/react-dev-utils/__tests__/ignoredFiles.test.js

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,33 @@
99

1010
const ignoredFiles = require('../ignoredFiles');
1111

12+
const anymatch = require('anymatch');
13+
1214
describe('ignore watch files regex', () => {
1315
it('normal file', () => {
1416
const appSrc = '/root/src/';
15-
const isIgnored = ignoredFiles(appSrc).test('/foo');
16-
const isIgnoredInSrc = ignoredFiles(appSrc).test('/root/src/foo');
17+
const isIgnored = anymatch(ignoredFiles(appSrc), '/foo');
18+
const isIgnoredInSrc = anymatch(ignoredFiles(appSrc), '/root/src/foo');
1719

1820
expect(isIgnored).toBe(false);
1921
expect(isIgnoredInSrc).toBe(false);
2022
});
2123

2224
it('node modules', () => {
2325
const appSrc = '/root/src/';
24-
const isIgnored = ignoredFiles(appSrc).test('/root/node_modules/foo');
26+
const isIgnored = anymatch(ignoredFiles(appSrc), '/root/node_modules/foo');
2527

2628
expect(isIgnored).toBe(true);
2729
});
2830

2931
it('node modules inside source directory', () => {
3032
const appSrc = '/root/src/';
31-
const isIgnored = ignoredFiles(appSrc).test('/root/src/node_modules/foo');
32-
const isIgnoredMoreThanOneLevel = ignoredFiles(appSrc).test(
33+
const isIgnored = anymatch(
34+
ignoredFiles(appSrc),
35+
'/root/src/node_modules/foo'
36+
);
37+
const isIgnoredMoreThanOneLevel = anymatch(
38+
ignoredFiles(appSrc),
3339
'/root/src/bar/node_modules/foo'
3440
);
3541

@@ -39,7 +45,8 @@ describe('ignore watch files regex', () => {
3945

4046
it('path contains source directory', () => {
4147
const appSrc = '/root/src/';
42-
const isIgnored = ignoredFiles(appSrc).test(
48+
const isIgnored = anymatch(
49+
ignoredFiles(appSrc),
4350
'/bar/root/src/node_modules/foo'
4451
);
4552

@@ -48,7 +55,10 @@ describe('ignore watch files regex', () => {
4855

4956
it('path starts with source directory', () => {
5057
const appSrc = '/root/src/';
51-
const isIgnored = ignoredFiles(appSrc).test('/root/src2/node_modules/foo');
58+
const isIgnored = anymatch(
59+
ignoredFiles(appSrc),
60+
'/root/src2/node_modules/foo'
61+
);
5262

5363
expect(isIgnored).toBe(true);
5464
});

0 commit comments

Comments
 (0)