jest-community / vscode-jest

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

Unable to run tests in .github/actions on Windows #1096

Open nbolton opened 11 months ago

nbolton commented 11 months ago

Environment

  1. vscode-jest version: v5.2.3
  2. node -v: v18.17.0 (direct install for testing; didn't use fnm/nvm)
  3. npm -v or yarn --version: npm 9.6.7
  4. npm ls jest or npm ls react-scripts:
    ├─┬ @testing-library/jest-dom@6.1.4
    │ └── jest@29.7.0 deduped
    ├── jest@29.7.0
    └─┬ ts-jest@29.1.1
    └── jest@29.7.0 deduped
  5. your vscode-jest settings if customized:
    • jest.jestCommandLine? Not set
    • jest.autoRun?
      "jest.autoRun": {
      "watch": false,
      "onSave": "test-src-file"
      },
  6. Operating system: Windows (works fine on macOS and Linux)

Prerequisite

Steps to Reproduce

  1. Have a .github/actions dir with unit tests
  2. Use the extension on macOS and Linux
  3. See that the .github tests pass
  4. Use the extension on Windows
  5. See that the .github tests fail

Expected Behavior

The workaround is to copy and paste the exact generated command from the Jest extension output directly to the terminal, which produces:

Test Suites: 2 passed, 2 total
Tests:       14 passed, 14 total
Snapshots:   0 total
Time:        2.658 s, estimated 6 s
Ran all test suites matching /c:\\project\\\.github/i

Actual Behavior

The command line generated is: jest --testLocationInResults --json --useStderr --outputFile C:\Users\username\AppData\Local\Temp\jest_runner_project_username_2.json --coverage --reporters default --reporters c:\Users\username\.vscode\extensions\orta.vscode-jest-5.2.3\out\reporter.js --colors --watchAll=false --testPathPattern c:\\project\\\.github

Note: Values edited (e.g. project and username) for privacy.

Which produces:

No tests found, exiting with code 1
Run with `--passWithNoTests` to exit with code 0
In C:\project
  453 files checked across 8 projects. Run with `--verbose` for more details.
Pattern: c:\project\\.github - 0 matches

The fastest (and the most fun) way to resolve the issue is to submit a pull-request yourself. If you are interested, feel free to check out the contribution guide, we look forward to seeing your PR...

connectdotz commented 11 months ago

hmm... this might be a bug... can you try to run the generated command directly in the terminal? Does it give you the same error? If it does, can you try to add one more backslash for the "testPathPattern": --testPathPattern c:\\project\\\\.github and see if that works.