diff --git a/jest.config.js b/jest.config.js index 18ad91a82b6d..cb4e3eb6ae0b 100644 --- a/jest.config.js +++ b/jest.config.js @@ -49,6 +49,7 @@ module.exports = { '/packages/jest-cli/src/init/__tests__/fixtures/', '/packages/jest-haste-map/src/__tests__/haste_impl.js', '/packages/jest-haste-map/src/__tests__/dependencyExtractor.js', + '/packages/jest-haste-map/src/__tests__/test_dotfiles_root', '/packages/jest-resolve-dependencies/src/__tests__/__fixtures__/', '/packages/jest-runtime/src/__tests__/defaultResolver.js', '/packages/jest-runtime/src/__tests__/module_dir/', diff --git a/packages/jest-haste-map/src/__tests__/includes_dotfiles.test.ts b/packages/jest-haste-map/src/__tests__/includes_dotfiles.test.ts new file mode 100644 index 000000000000..990a8d7bf849 --- /dev/null +++ b/packages/jest-haste-map/src/__tests__/includes_dotfiles.test.ts @@ -0,0 +1,48 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +import path from 'path'; +import HasteMap from '../index'; + +const rootDir = path.join(__dirname, './test_dotfiles_root'); + +const commonOptions = { + extensions: ['js'], + maxWorkers: 1, + platforms: [], + resetCache: true, + retainAllFiles: true, + rootDir, + roots: [rootDir], +}; + +test('watchman crawler and node crawler both include dotfiles', async () => { + const hasteMapWithWatchman = new HasteMap({ + ...commonOptions, + name: 'withWatchman', + useWatchman: true, + }); + + const hasteMapWithNode = new HasteMap({ + ...commonOptions, + name: 'withNode', + useWatchman: false, + }); + + const [builtHasteMapWithWatchman, builtHasteMapWithNode] = await Promise.all([ + hasteMapWithWatchman.build(), + hasteMapWithNode.build(), + ]); + + expect( + builtHasteMapWithWatchman.hasteFS.matchFiles('.eslintrc.js'), + ).toHaveLength(1); + + expect(builtHasteMapWithWatchman.hasteFS.getAllFiles().sort()).toEqual( + builtHasteMapWithNode.hasteFS.getAllFiles().sort(), + ); +}); diff --git a/packages/jest-haste-map/src/__tests__/test_dotfiles_root/.eslintrc.js b/packages/jest-haste-map/src/__tests__/test_dotfiles_root/.eslintrc.js new file mode 100644 index 000000000000..b6861b5fb248 --- /dev/null +++ b/packages/jest-haste-map/src/__tests__/test_dotfiles_root/.eslintrc.js @@ -0,0 +1,6 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ diff --git a/packages/jest-haste-map/src/__tests__/test_dotfiles_root/index.js b/packages/jest-haste-map/src/__tests__/test_dotfiles_root/index.js new file mode 100644 index 000000000000..b6861b5fb248 --- /dev/null +++ b/packages/jest-haste-map/src/__tests__/test_dotfiles_root/index.js @@ -0,0 +1,6 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ diff --git a/packages/jest-haste-map/src/crawlers/watchman.ts b/packages/jest-haste-map/src/crawlers/watchman.ts index 2ee8a5a88fda..5d47d33f8842 100644 --- a/packages/jest-haste-map/src/crawlers/watchman.ts +++ b/packages/jest-haste-map/src/crawlers/watchman.ts @@ -126,7 +126,7 @@ export = async function watchmanCrawl( ? // Use the `since` generator if we have a clock available {expression, fields, since: clocks.get(relativeRoot)} : // Otherwise use the `glob` filter - {expression, fields, glob}; + {expression, fields, glob, glob_includedotfiles: true}; const response = await cmd('query', root, query);