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

[Bug]: v30-alpha.5 TestPathPatterns pattern-match regression #15109

Open
connectdotz opened this issue Jun 7, 2024 · 2 comments
Open

[Bug]: v30-alpha.5 TestPathPatterns pattern-match regression #15109

connectdotz opened this issue Jun 7, 2024 · 2 comments

Comments

@connectdotz
Copy link
Contributor

connectdotz commented Jun 7, 2024

Version

30.0.0-alpha.5

Steps to reproduce

This can be demonstrated with jest's own examples/getting-started on a Window vscode powershell terminal:

  1. clone https://github.com/jestjs/jest
  2. copy the examples/getting-started to a new folder outside of Jest, so we can change the jest version freely.
  3. goto this standalone getting-started folder
  4. edit package.json to change the jest and babel-jest versions to 30.0.0-alpha.5
  5. yarn install
  6. run a specific test like this in a powershell terminal:
> yarn jest --testLocationInResults --testNamePattern "adds 1 \+ 2 to equal 3$" --no-coverage --colors --watchAll=false --testPathPatterns "c:\\Users\\dev\\github\\open-source\\getting-started\\sum\.test\.js"

Expected behavior

Expect this to work just like with jest 29.x.

Edit package.json to update jest and babel-jest to 29.7.0; run yarn install then run the command again (replacing --TestPathPatterns with --TestPathPattern):

PS C:\Users\dev\github\open-source\getting-started> yarn jest --testLocationInResults --testNamePattern "adds 1 \+ 2 to equal 3$" --no-coverage --colors --watchAll=false --testPathPattern "c:\\Users\\dev\\github\\open-source\\getting-started\\sum\.test\.js"
js";dbee3b2e-0ab6-4105-a99f-3a96e3b4cf5eyarn run v1.22.19                                             i
$ C:\Users\dev\github\open-source\getting-started\node_modules\.bin\jest --testLocationInResults --testNamePattern "adds 1 \+ 2 to equal 3$" --no-coverage --colors --watchAll=false --testPathPattern c:\\Users\\dev\\github\\open-source\\getting-started\\sum\.test\.js
 PASS  ./sum.test.js
  √ adds 1 + 2 to equal 3 (2 ms)

Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        0.669 s, estimated 1 s
Ran all test suites matching /c:\\Users\\dev\\github\\open-source\\getting-started\\sum\.test\.js/i with tests matching "adds 1 \+ 2 to equal 3$".
Done in 1.23s.

Actual behavior

the pattern match failed so no test is run:

PS C:\Users\dev\github\open-source\getting-started> yarn jest --testLocationInResults --testNamePattern "adds 1 \+ 2 to equal 3$" --no-coverage --colors --watchAll=false --testPathPatterns "c:\\Users\\dev\\github\\open-source\\getting-started\\sum\.test\.js"
yarn run v1.22.19
$ C:\Users\dev\github\open-source\getting-started\node_modules\.bin\jest --testLocationInResults --testNamePattern "adds 1 \+ 2 to equal 3$" --no-coverage --colors --watchAll=false --testPathPatterns c:\\Users\\dev\\github\\open-source\\getting-started\\sum\.test\.js
No tests found, exiting with code 1
Run with `--passWithNoTests` to exit with code 0
In C:\Users\dev\github\open-source\getting-started
  4 files checked.
  testMatch: **/__tests__/**/*.?([mc])[jt]s?(x), **/?(*.)+(spec|test).?([mc])[jt]s?(x) - 1 match      
  testPathIgnorePatterns: \\node_modules\\ - 4 matches
  testRegex:  - 0 matches
Pattern: c:\\Users\\dev\\github\\open-source\\getting-started\\sum\.test\.js - 0 matches
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Additional context

  • This issue only occurs on Windows. It works as expected on macOS, as far as I can tell.
  • Also noticed jest seems to perform a case-insensitive match for TestPathPattern in v29.x. Can't tell if v30 is doing the same.

Environment

System:
    OS: Windows 10 10.0.19045
    CPU: (12) x64 Intel(R) Core(TM) i7-8700B CPU @ 3.20GHz
  Binaries:
    Node: 20.11.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 10.2.4 - C:\Program Files\nodejs\npm.CMD
  npmPackages:
    jest: ^30.0.0-alpha.5 => 30.0.0-alpha.5
@connectdotz
Copy link
Contributor Author

@SimenB any insight on this issue?

@connectdotz
Copy link
Contributor Author

@SimenB, sorry to ping you again. This issue has blocked the release of our jest@30 support PR (jest-community/vscode-jest#1153). Has the path-regex-matching algorithm changed intentionally? The same path pattern is recognized in v29 but not in v30. If this is a breaking change in v30 and not a bug, please let us know the right path forward so we can fix the PR and start to support jest@30 users.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant