Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows watch mode fix #3563

Merged
merged 9 commits into from
May 17, 2017
Original file line number Diff line number Diff line change
Expand Up @@ -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, '/');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain why we need to replace two backslashes with a single slash? Where does the second backslash come from?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess because we're dealing with a pattern, so it needs an escape.

Copy link
Contributor Author

@scottambroseio scottambroseio May 16, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was the original problem the function is trying to fix

970c1bf0-341a-11e7-92d2-09fc3f05c9de

Due to the backslashs needing escaping, the way I understand it is that behind the hood path\\to\\file is actually path\\\\to\\\\file, if that makes sense?

Edit: Yeah, you summarised it better than I could.


contexts[0].config = {rootDir: ''};
watch(globalConfig, contexts, argv, pipe, hasteMapInstances, stdin);

Expand All @@ -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', () => {
Expand Down
5 changes: 3 additions & 2 deletions packages/jest-cli/src/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -201,7 +202,7 @@ const watch = (
testPathPattern => {
updateArgv(argv, 'watch', {
testNamePattern: '',
testPathPattern,
testPathPattern: replacePathSepForRegex(testPathPattern),
});

startRun();
Expand Down