Vscode-jest: Tests not found - Windows

Created on 6 Mar 2019  路  1Comment  路  Source: jest-community/vscode-jest

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鈥檛 ejected): [email protected]
  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

  • are you able to run jest test from command line? Yes
  • how do you run your tests from command line? (for example: npm run test or node_modules/.bin/jest) npm run test:watch

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):

> [email protected] test C:\Users\menachem\source\repos\project\ClientApp
> react-scripts test --env=jsdom

Command output in Jest

> [email protected] 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.

Most helpful comment

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

>All comments

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

Was this page helpful?
0 / 5 - 0 ratings