question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

testPathPattern is messed up when running test

See original GitHub issue

Environment

  1. vscode-jest version: 4.2.1

  2. node -v: v16.13.1

  3. npm --version: 8.1.2

  4. npm ls jest or npm ls react-scripts (if you haven’t ejected): react-scripts@5.0.0

  5. your vscode-jest settings if customized:

    • jest.jestCommandLine? npm test –
    • jest.autoRun? off
  6. Operating system: Windows 11

Prerequisite

  • are you able to run jest test from the command line? yes
  • how do you run your tests from the command line? (for example: npm run test or node_modules/.bin/jest) npm test --watchAll=false

Steps to Reproduce

  1. create-react-app project
  2. run the “renders learn react link”

Expected Behavior

the tests should run normally

Actual Behavior

my-app@0.1.0 test react-scripts test “–testLocationInResults” “–json” “–useStderr” “–outputFile” “C:\Users\smars\AppData\Local\Temp\jest_runner_my_app.json” “–testNamePattern” “renders learn react link” “–no-coverage” “–reporters” “default” “–reporters” “c:\Users\smars\.vscode\extensions\orta.vscode-jest-4.2.1\out\reporter.js” “–colors” “–watchAll=false” “–testPathPattern” “d:\\repos\\my-app\\src\\App\.test\.tsx”

No tests found, exiting with code 1 Run with --passWithNoTests to exit with code 0 In D:\repos\my-app 6 files checked. testMatch: D:/repos/my-app/src//tests//.{js,jsx,ts,tsx}, D:/repos/my-app/src/**/.{spec,test}.{js,jsx,ts,tsx} - 1 match testPathIgnorePatterns: \node_modules\ - 6 matches testRegex: - 0 matches Pattern: d:\\repos\\my-app\\src\\App\.test\.tsx - 0 matches


for some reason the testPathPattern is messed up. it works fine when i use yarn as the command

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:4
  • Comments:18

github_iconTop GitHub Comments

2reactions
connectdotzcommented, Oct 24, 2022

for people who had problems with testPathPattern, i.e. npm miss-interpreting the pass-through arguments: it seems npm @>=8.15 has fixed this issue. 🎉

0reactions
WillisShekcommented, Oct 4, 2022

With cross-env, the double backslash doesn’t work. For example, cross-env NODE_ENV=test jest --testPathPattern c:\\folder\\test won’t work, while cross-env NODE_ENV=test jest --testPathPattern c:\\\folder\\\test will work. This is probably the responsibility of cross-env but since cross-env is not in active development so we may have to find some other alternative.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Trying to use -t or --testNamePattern in Jest runs all tests
I can run that test only with yarn test --testPathPattern='processNewUser'. But If I try use yarn test --testNamePattern='Processes new user ...
Read more >
Angular 14 + Jest: tests running fails with "Unknown arguments
Angular 14 + Jest: tests running fails with "Unknown arguments: testNamePattern, testPathPattern" · 1. Setup an Angular project with Jest as testing framework....
Read more >
Jest CLI Options
Contrary to --testPathPattern , it will only run those tests with a path that does not match with the provided regexp expressions. --testRunner=<path>....
Read more >
Heft command line - Rush Stack
test Build the project and run tests. ... heft test​. (Help is shown with @rushstack/heft-jest-plugin configured.) ... If you suspect a problem with...
Read more >
React end-to-end testing with Jest and Puppeteer
The --testPathPattern means that Jest will only run files that have the pattern e2e.test.js . Before we run the test, we need to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found