question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Jest runs tests under .git by default

See original GitHub issue

Do you want to request a feature or report a bug?

bug

What is the current behavior?

Jest runs tests on branches in git when the branch name ends with “.spec.js” or “.test.js” (e.g. “.git/refs/remotes/origin/example.spec.js”).

If the current behavior is a bug, please provide the steps to reproduce and either a repl.it demo through https://repl.it/languages/jest or a minimal repository on GitHub that we can yarn install and yarn test.

What is the expected behavior?

Jest ignores/excludes files under “.git” by default (or perhaps even under any directory that begins with a dot).

Please provide your exact Jest configuration and mention your Jest, node, yarn/npm version and operating system.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:16 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
thymikeecommented, Feb 6, 2018

Honestly that never happened to me. Do you have a repro?

1reaction
amazzocconecommented, Jan 4, 2019

Same here!

Error: Cannot parse /{my-path}/.git/logs/refs/remotes/upstream/package.json as JSON: Unexpected number in JSON at position 1
    at Object.<anonymous> (/{my-path}/node_modules/jest-haste-map/build/worker.js:56:15)
    at Generator.next (<anonymous>)
    at step (/{my-path}/node_modules/jest-haste-map/build/worker.js:192:30)
    at /{my-path}/node_modules/jest-haste-map/build/worker.js:211:14
    at new Promise (<anonymous>)
    at Object.<anonymous> (/{my-path}/node_modules/jest-haste-map/build/worker.js:189:12)
    at Object.worker (/{my-path}/node_modules/jest-haste-map/build/worker.js:95:17)
    at execMethod (/Users/andresmazzo/Code/Sites/bonda-pwa/node_modules/jest-worker/build/child.js:90:29)
    at process.on (/{my-path}/node_modules/jest-worker/build/child.js:40:7)
    at process.emit (events.js:180:13)

After a looooong research at work i fixed it removing upstream (git remote rm upstream) 🎉. Really weird, but it checks that jest was running under .git.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Jest CLI Options
Run all tests (default):. jest. Run only the tests that were specified with a pattern or filename: jest my-test #or jest path/to/my-test.js.
Read more >
Run jest for unit tests of modified files only | by SunCommander
In this article, you will learn how to run Jest for modified files only in a Pull Request. This can be done using...
Read more >
Jest testing: Top features and how to use them - LogRocket Blog
Jest integrates with Git and Mercurial. By default, the watch mode will run only the tests affected by the changes made since the...
Read more >
Jest CLI Options - Robin Pokorny
Run all tests (default): jest. Run only the tests that were specified with a ... Run tests related to changed files based on...
Read more >
How do I run a single test using Jest? - Stack Overflow
If you are using Visual Studio Code you can take advantage of it and run the currently selected test (in the code editor)...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found