Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix Jest "No Tests Found" on windows 10?

Tags:

jestjs

I am trying to use Jest on my windows 10 desktop computer, but it keeps telling me that there are no tests found. On my windows 10 laptop, it works just fine. Here is the output I am getting on my desktop:

C:\app> jest
No tests found
In C:\app
   25163 files checked.
   testMatch: **/__tests__/**/*.js?(x),**/?(*.)(spec|test).js?(x) - 743 matches
   testPathIgnorePatterns: \\node_modules\\ - 25163 matches
Pattern: "" - 0 matches

In my package.json file, my jest config looks like this:

"jest": {
  "collectCoverageFrom": [
    "app/**/*.{js,jsx}",
    "!app/**/*.test.{js,jsx}",
    "!app/*/RbGenerated*/*.{js,jsx}",
    "!app/app.js"
  ],
  "coverageThreshold": {
    "global": {
      "statements": 98,
      "branches": 91,
      "functions": 98,
      "lines": 98
    }
  },
  "moduleDirectories": [
    "node_modules",
    "app",
    "common"
  ],
  "moduleNameMapper": {
    ".*\\.(css|less|styl|scss|sass)$": "<rootDir>/internals/mocks/cssModule.js",
    ".*\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/internals/mocks/image.js"
  },
  "setupTestFrameworkScriptFile": "<rootDir>/internals/testing/test-bundler.js"
}

I am using node 8.1.4 and jest v20.0.4 Any ideas on how to get jest to locate my tests?

like image 341
Andy Hansen Avatar asked Jul 16 '17 19:07

Andy Hansen


2 Answers

I am not 100% sure its the same issue. But what solved it for me was to get rid of watchman (I added it in on path for another project that used relay). Try to run with --no-watchman (or set watchman: false in jest config)

like image 168
MatijaG Avatar answered Nov 04 '22 19:11

MatijaG


Seeing this issue with Jest 24.8.0. It seems if you add --runTestsByPath it will correctly handle forward/backspaces,

There is a discussion of the issue https://github.com/microsoft/vscode-recipes/issues/205#issuecomment-533645097, with the following suggested VSCode debug configuration

{
  "type": "node",
  "request": "launch",
  "name": "Jest Current File",
  "program": "${workspaceFolder}/node_modules/.bin/jest",
  "args": [
   "--runTestsByPath",   // This ensures the next line is treated as a path
   "${relativeFile}",    // This path may contain backslashes on windows
    "--config",
    "jest.config.js"
  ],
  "console": "integratedTerminal",
  "internalConsoleOptions": "neverOpen",
  "disableOptimisticBPs": true,
  "windows": {
    "program": "${workspaceFolder}/node_modules/jest/bin/jest",
  }
}
like image 20
FrozenKiwi Avatar answered Nov 04 '22 20:11

FrozenKiwi