Skip to content

Commit

Permalink
also validate in haste-map
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Nov 2, 2020
1 parent 5c365ab commit d0bccc4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
20 changes: 20 additions & 0 deletions e2e/__tests__/crawlSymlinks.test.ts
Expand Up @@ -6,6 +6,7 @@
*/
import {tmpdir} from 'os';
import * as path from 'path';
import {wrap} from 'jest-snapshot-serializer-raw';
import {cleanup, writeFiles, writeSymlinks} from '../Utils';
import runJest from '../runJest';

Expand Down Expand Up @@ -69,3 +70,22 @@ test('Node crawler does not pick up symlinked files by default', () => {
expect(stderr).toEqual('');
expect(exitCode).toEqual(1);
});

test('Should throw if watchman used with haste.enableSymlinks', () => {
init({'.watchmanconfig': JSON.stringify({})});

const {stdout, stderr, exitCode} = runJest(DIR, [
'--haste={"enableSymlinks": true}',
'--watchman',
]);

expect(stdout).toEqual('');
expect(wrap(stderr)).toMatchInlineSnapshot(`
Validation Error:
haste.enableSymlinks is incompatible with watchman
Either set haste.enableSymlinks to false or do not use watchman
`);
expect(exitCode).toEqual(1);
});
8 changes: 8 additions & 0 deletions packages/jest-haste-map/src/index.ts
Expand Up @@ -278,6 +278,14 @@ class HasteMap extends EventEmitter {
this._options.ignorePattern = new RegExp(VCS_DIRECTORIES);
}

if (this._options.enableSymlinks && this._options.useWatchman) {
throw new Error(
'jest-haste-map: enableSymlinks config option was set, but ' +
'is incompatible with watchman.\n' +
'Set either `enableSymlinks` to false or `watchman` to false ',
);
}

const rootDirHash = createHash('md5').update(options.rootDir).digest('hex');
let hasteImplHash = '';
let dependencyExtractorHash = '';
Expand Down

0 comments on commit d0bccc4

Please sign in to comment.