Skip to content

Commit d53f7c0

Browse files
Scott Rangercpojer
authored andcommitted
Windows watch mode fix (#3563)
* Fix interactive watch arrow selection on Windows #3516 * Refactored fix for #3516 to use replacePathSepForRegex * Fixed the failing test on Windows for the #3516 fix * Bump regex-slash to 1.0.1 (provides a flow lib def) * Update watch-filename-pattern-mode-test.js * Code review feedback * Fixed lint errors and implemented PR feedback * Revert yarn.lock changes
1 parent 2a0001d commit d53f7c0

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

packages/jest-cli/src/__tests__/watch-filename-pattern-mode-test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ describe('Watch mode flows', () => {
145145
});
146146

147147
it('can select a specific file name from the typeahead results', () => {
148+
const toUnixPathPattern = pathPattern => pathPattern.replace(/\\\\/g, '/');
149+
148150
contexts[0].config = {rootDir: ''};
149151
watch(globalConfig, contexts, argv, pipe, hasteMapInstances, stdin);
150152

@@ -164,7 +166,7 @@ describe('Watch mode flows', () => {
164166

165167
stdin.emit(KEYS.ENTER);
166168

167-
expect(argv.testPathPattern).toMatchSnapshot();
169+
expect(toUnixPathPattern(argv.testPathPattern)).toMatchSnapshot();
168170
});
169171

170172
it('Results in pattern mode get truncated appropriately', () => {

packages/jest-cli/src/watch.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@ import type {Context} from 'types/Context';
1414

1515
const ansiEscapes = require('ansi-escapes');
1616
const chalk = require('chalk');
17+
const {replacePathSepForRegex} = require('jest-regex-util');
1718
const HasteMap = require('jest-haste-map');
1819
const isCI = require('is-ci');
19-
const createContext = require('./lib/createContext');
2020
const isValidPath = require('./lib/isValidPath');
2121
const preRunMessage = require('./preRunMessage');
22+
const createContext = require('./lib/createContext');
2223
const runJest = require('./runJest');
2324
const updateArgv = require('./lib/updateArgv');
2425
const SearchSource = require('./SearchSource');
@@ -201,7 +202,7 @@ const watch = (
201202
testPathPattern => {
202203
updateArgv(argv, 'watch', {
203204
testNamePattern: '',
204-
testPathPattern,
205+
testPathPattern: replacePathSepForRegex(testPathPattern),
205206
});
206207

207208
startRun();

0 commit comments

Comments
 (0)