Jest: Jest 26.2.1 regression: “No tests found” on Windows

Created on 30 Jul 2020  ·  19Comments  ·  Source: facebook/jest

🐛 Bug Report

In PostCSS we found a problem with the new Jest release. After updating Jest to 26.2.1, Jest stopped to see tests on Windows in our Travis CI.

$ npx jest

No tests found, exiting with code 1
Run with `--passWithNoTests` to exit with code 0
No files found in C:\Users\travis\build\postcss\postcss.
Make sure Jest's configuration does not exclude this directory.
To set up Jest, make sure a package.json file exists.
Jest Documentation: facebook.github.io/jest/docs/configuration.html
Pattern:  - 0 matches
The command "npx jest" exited with 1.

To Reproduce

Seems like just call npx jest on Windows. Here is a config to call it on Travis CI

matrix:
  include:
    os: windows
    cache: false
    node_js: node
    script: npx jest
    env:
      - YARN_GPG=no

Expected behavior

https://travis-ci.org/github/postcss/postcss/jobs/713424784

Link to repl or repo (highly encouraged)

https://github.com/postcss/postcss/archive/8722140c5c55530b0c4091190f1557b42fd18c87.zip

envinfo

  System:
    OS: Windows 10 10.0.17763
    CPU: (2) x64 Intel(R) Xeon(R) CPU
  Binaries:
    Node: 14.7.0 - C:\ProgramData\nvs\node\14.7.0\x64\node.EXE
    Yarn: 1.22.4 - ~\.yarn\bin\yarn.CMD
    npm: 6.14.7 - C:\ProgramData\nvs\node\14.7.0\x64\npm.CMD
  npmPackages:
    jest: ^26.2.1 => 26.2.1 
Regression Help Wanted Windows

Most helpful comment

All 19 comments

Strange thing that even ts-jest hasn’t updated to jest 26.2.x but also saw the same issue https://travis-ci.com/github/kulshekhar/ts-jest/jobs/366826311

The issue occured right after 26.2 was released and CI still uses 26.1, and of course all PRs by dependabot to upgrade to jest 26.2 failed with the same reason.

The issue however only happens to ts-jest node 14 tests on external projects, unit tests on node 10 Windows work fine https://travis-ci.com/github/kulshekhar/ts-jest/jobs/366826310

Seem like PostCSS and ts-jest CIs both failed with Node 14 Windows

This affects me as well. I use Windows with Node v12.18.3 and Jest v26.2.1. Ts-Jest is at 26.1.4.

I don't have access to a windows machine, unfortunately, so hard for me to debug this... Our own Windows CI passes on both GH Actions and Azure Pipelines, so I wonder if this is some weird config thing?

Does it _just_ happen with ts-jest?

@SimenB yeap, we have TypeScript tests too

I tried to run ts-jest CI on tag 26.1.4 (which is the latest release) also failed with Windows Node 14. Tag 26.1.4 doesn't use jest 26.2 for e2e tests https://github.com/kulshekhar/ts-jest/blob/220f4fbfd2544ad23af494c2d5acd53d28fdac74/e2e/__external-repos__/custom-typings/yarn.lock#L296

The only clue I have is CI didn't fail with 26.1 until 26.2 released

I'm guessing this is somehow related to #10308 - only windows change I can think of (although it's weird that our own tests pass...).

Does anyone here use Windows on their own machine, or have the possibility to test? If so, try reverting this change

image

in node_modules/jest-haste-map/build/crawlers/node.js. That should force an fs crawl using Node's APIs rather than using find on windows

I think maybe an alpha version so we can point CI to it ?

I'd rather avoid it if possible, but not a huge issue if no one here has a Windows machine

Tests not being detected on WIndows. I use yarn, ts-jest for typescript.

Do we have an interim solution for windows?
Version is automatically being pointed to 26.2.1 even thought i explicitly mention ~26.1.0

Interim solution is to revert the upgrade commit if you have a lockfile. For fresh installs you could try to use resolutions

I'm guessing this is somehow related to #10308 - only windows change I can think of (although it's weird that our own tests pass...).

Does anyone here use Windows on their own machine, or have the possibility to test? If so, try reverting this change

image

in node_modules/jest-haste-map/build/crawlers/node.js. That should force an fs crawl using Node's APIs rather than using find on windows

yes, as soon as you undo the change, it will run on Windows systems again.

I was able to find the old windows images from modern.ie, and was able to confirm it. I'll try a couple of minutes to fix detection properly, if not I'll re-add the condition 👍 I'm very confused by why our CI passes with the changes...

Thanks a lot Simen !!, I see our CI is green again

Thanks, I also had problems with my tests after upgrade to version 26.2.1 but with 26.2.2 everything is working again. Thanks again.

@SimenB stumbled on this while lazily scrolling through the issues - I dev on Windows (w/ WSL for CLI) so feel free to ping me on future Windows issues if you'd like :)

Thanks @G-Rath! Will do 🙂

Hi, I still have this issue with 26.2.2 or later on one of my windows machines (on others it does work). On the machine where it does not work, I can make it work by manually changing forceNodeFilesystemAPI in jest-haste-map (packages/jest-haste-map/src/crawlers/node.ts) to true.

Was this page helpful?
0 / 5 - 0 ratings