diff --git a/packages/jest-cli/src/__tests__/watch-filename-pattern-mode-test.js b/packages/jest-cli/src/__tests__/watch-filename-pattern-mode-test.js index 2d3429fcb842..b88083bada53 100644 --- a/packages/jest-cli/src/__tests__/watch-filename-pattern-mode-test.js +++ b/packages/jest-cli/src/__tests__/watch-filename-pattern-mode-test.js @@ -145,6 +145,8 @@ describe('Watch mode flows', () => { }); it('can select a specific file name from the typeahead results', () => { + const toUnixPathPattern = pathPattern => pathPattern.replace(/\\\\/g, '/'); + contexts[0].config = {rootDir: ''}; watch(globalConfig, contexts, argv, pipe, hasteMapInstances, stdin); @@ -164,7 +166,7 @@ describe('Watch mode flows', () => { stdin.emit(KEYS.ENTER); - expect(argv.testPathPattern).toMatchSnapshot(); + expect(toUnixPathPattern(argv.testPathPattern)).toMatchSnapshot(); }); it('Results in pattern mode get truncated appropriately', () => { diff --git a/packages/jest-cli/src/watch.js b/packages/jest-cli/src/watch.js index a28153c5e5b8..98ab73a53905 100644 --- a/packages/jest-cli/src/watch.js +++ b/packages/jest-cli/src/watch.js @@ -14,11 +14,12 @@ import type {Context} from 'types/Context'; const ansiEscapes = require('ansi-escapes'); const chalk = require('chalk'); +const {replacePathSepForRegex} = require('jest-regex-util'); const HasteMap = require('jest-haste-map'); const isCI = require('is-ci'); -const createContext = require('./lib/createContext'); const isValidPath = require('./lib/isValidPath'); const preRunMessage = require('./preRunMessage'); +const createContext = require('./lib/createContext'); const runJest = require('./runJest'); const updateArgv = require('./lib/updateArgv'); const SearchSource = require('./SearchSource'); @@ -201,7 +202,7 @@ const watch = ( testPathPattern => { updateArgv(argv, 'watch', { testNamePattern: '', - testPathPattern, + testPathPattern: replacePathSepForRegex(testPathPattern), }); startRun();