jest-community / vscode-jest

The optimal flow for Jest based testing in VS Code
MIT License
2.83k stars 290 forks source link

Tests not found - Windows #432

Closed mhornbacher closed 5 years ago

mhornbacher commented 5 years ago

Environment

  1. node -v: v10.15.1

  2. npm -v: 6.4.1

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

  4. your vscode-jest settings if customized:

    • jest.pathToJest? "npm run test:watch"
    • jest.pathToConfig? unset
    • jest.rootPath? "./ClientApp"
    • anything else that you think might be relevant? React app is in a subfolder called ClientApp
  5. Operating system: Windows 10 Pro (10.0.17134)

Prerequisite

Steps to Reproduce

  1. Setup a repo using dotnet new reactredux
  2. Load up in VS Code with this extension installed.
  3. Open a terminal and run dotnet restore on the root directory (optional)
  4. Run cd ClientApp and npm install to install dependencies
  5. Start the jest runner from this extension
  6. Go to the output tab on the bottom and select jest from the dropdown.

Relevant Debug Info

Running on console finds ClientApp/src/tests/App.test.tsx while it appears that the same command from the same location in this extension does not.

Command run in Powershell (npm run test:watch):

> my-pushka@0.1.0 test C:\Users\menachem\source\repos\project\ClientApp
> react-scripts test --env=jsdom

Command output in Jest

> my-pushka@0.1.0 test c:\Users\menachem\source\repos\project\ClientApp
> react-scripts test --env=jsdom "C:\Users\menachem\AppData\Local\Temp/jest_runner.json"

No tests found
In c:\Users\menachem\source\repos\project\ClientApp
  15 files checked.
  testMatch: c:\Users\menachem\source\repos\project\ClientApp\src\**\__tests__\**\*.{js,jsx,ts,tsx},c:\Users\menachem\source\repos\project\ClientApp\src\**\?(*.)(spec|test).{js,jsx,ts,tsx} - 1 match
  testPathIgnorePatterns: \\node_modules\\ - 15 matches
Pattern: C:\Users\menachem\AppData\Local\Temp\\jest_runner.json - 0 matches

npm
 ERR! Test failed.  See above for more details.

Finished running all tests. Starting watch mode.

This repeats a few times until the extension stops.

Expected Behavior

Tests should be found (as they are on the command line) and run accordingly.

Actual Behavior

Tests are not found causing extension to fail.

mhornbacher commented 5 years ago

Resolved by adding -- to the configuration as per @guylando in #342

Specifically "jest.pathToJest": "npm run test:watch", to "jest.pathToJest": "npm run test:watch --", in .vscode/settings.json