-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Interactive watch arrow selection doesn't work on Windows. #3516
Comments
Would you like to send a PR with a fix? 🙂 |
If I find some time, I will. Created the ticket in case someone else got to it before I do. |
I had some free time today so I took a bash at fixing this, here's my findings. Here's a diff with a simple but working solution. I don't know the code base that well at all so I'm not sure if there's a better place to do this logic. Secondly, this change breaks one of the tests but I'm not sure how best to resolve it, as the test passing or failing depends on the operating system the test is being run on. |
@scottrangerio in The test may be fixed with const slash = require('slash');
expect(slash(argv.testPathPattern)).toMatchSnapshot(); We use it to normalize paths in tests on Unix/Windows platforms. |
I'm wondering if we can normalize it instead so that watch mode would support |
@thymikee thanks for the suggestions / input! The The test isn't actually testing a path, but a regular expression which represents a path. So rather than calling |
I've been thinking some more about a non hack way to fix the test on windows. I really like the slash idea, so I was thinking that something simple like this could do the job. // regex-slash.js
// could be hosted as a npm module like slash, or simply included somewhere like in jest-regex-util
'use strict';
// path\\to\\file.js -> path/to/file.js
module.exports = (str: string): string => {
return str.replace(/\\\\/g, '/');
}; usage: const rslash = require('regex-slash');
expect(rslash(argv.testPathPattern)).toMatchSnapshot(); |
* 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
* Fix interactive watch arrow selection on Windows jestjs#3516 * Refactored fix for jestjs#3516 to use replacePathSepForRegex * Fixed the failing test on Windows for the jestjs#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
* Fix interactive watch arrow selection on Windows jestjs#3516 * Refactored fix for jestjs#3516 to use replacePathSepForRegex * Fixed the failing test on Windows for the jestjs#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
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Do you want to request a feature or report a bug?
bug
What is the current behavior?
Using the new arrow selection for patterns in watch mode does not work on Windows. It correctly selects the entry but I believe because of the slashes it's not finding any tests.
Arrow selection pattern: /_Common/Upload/Html5/FileUploadSpec.ts/
Actual pattern: /_Common\\Upload\\Html5\\FileUploadSpec.ts/
What is the expected behavior?
It should find the tests based off the arrow selection.
Please provide your exact Jest configuration and mention your Jest, node, yarn/npm version and operating system.
Jest 20
Yarn 0.23.4
Windows 10
The text was updated successfully, but these errors were encountered: