-
Notifications
You must be signed in to change notification settings - Fork 310
Description
Describe the bug
Instead of a backslash, a caret is used to escape special characters in the testNamePattern when running an individual test through the UI.
This causes the test to be skipped.
What I also find curious is that the testNamePattern is included in the command at all. I'm running the entire test file, I don't understand why it's including it since the testPathPattern already narrows it down to the file exclusively.
describe("foo >", () => {
it("bar", () => {
expect(1).toBe(1);
});
});Test Suites: 1 skipped, 0 of 1 total
Tests: 1 skipped, 1 total
Snapshots: 0 total
Time: 1.262 s
Ran all test suites matching [omitted]jest-repro\\src\\App\.test\.js/i with tests matching "foo ^> bar$".
Spawn command: [Extension Host] spawning process with command=npm test -- --testLocationInResults --json --useStderr --outputFile [omitted] --testNamePattern "foo ^> bar$" --no-coverage --reporters default --reporters "[omitted]" --colors --watchAll=false --testPathPattern "[omitted]\\src\\App\.test\.js"
I added more special characters to see which ones are affected:
describe("foo ` ~ ! @ # $ % ^ & * ( ) { } [ ] / = ? + _ - , . < > ' \"", () => {
it("bar", () => {
expect(1).toBe(1);
});
});Test Suites: 1 skipped, 0 of 1 total
Tests: 1 skipped, 1 total
Snapshots: 0 total
Time: 1.712 s
Ran all test suites matching [omitted]\\src\\App\.test\.js/i with tests matching "foo ` ~ ^! @ # \$ % \^^ ^& \* \( \) \{ \} \[ \] / = \? \+ _ - , \. ^< ^> ' " bar$".
! ^ & < > are affected.
To Reproduce
Sample repo
Steps to reproduce the behavior:
- Run the single test in the UI
- See error
Expected behavior
Backslashes are used to escape special characters in the testNamePattern.
Environment (please complete the following information):
- vscode-jest version: v6.2.5
node -v: 21.6.1, also tested on LTS 20.17.0npm -voryarn --version: npm 10.2.4- jest or react-scripts (if you haven’t ejected) version: react-scripts 5.0.1 (also tested on company's repo using Jest v29.7.0, no react-scripts)
- your vscode-jest settings:
- jest.jestCommandLine? N/A
- jest.runMode? on-demand
- jest.outputConfig? none
- anything else that you think might be relevant? The error was reproduced by all my colleagues, with varying setups, although all running Windows 11.
- Operating system: Windows 11 Business version 23H2
Prerequisite
- are you able to run jest from the command line? yes
- where do you run jest CLI from? root directory of the project
- how do you run your tests from the command line?
npm run test,npx jest