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 fails when git branch name looks like a json file

See original GitHub issue

🐛 Bug Report

Jest hard-fails with an exit code if the git branch is named package.json

To Reproduce

Steps to reproduce the behavior:

  • Create a git branch named fix/package.json
  • Push the branch to a remote
  • Run jest jest --coverage

Expected behavior

Jest runs as normal

Actual behavior

Jest errors because it perceives the git reference marker file as a JSON file (because of the filename) and attempts to parse that reference marker as JSON (which it isn’t, and never would be)

Screen Shot 2020-04-16 at 2 14 43 PM
> jest --coverage

Error: Cannot parse /Users/c050004/Documents/git/logger/.git/refs/heads/fix/package.json as JSON: Unexpected token e in JSON at position 0
    at Object.<anonymous> (/Users/c050004/Documents/git/logger/node_modules/jest-haste-map/build/worker.js:167:15)
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (/Users/c050004/Documents/git/logger/node_modules/jest-haste-map/build/worker.js:78:24)
    at _next (/Users/c050004/Documents/git/logger/node_modules/jest-haste-map/build/worker.js:98:9)
    at /Users/c050004/Documents/git/logger/node_modules/jest-haste-map/build/worker.js:103:7
    at new Promise (<anonymous>)
    at Object.<anonymous> (/Users/c050004/Documents/git/logger/node_modules/jest-haste-map/build/worker.js:95:12)
    at Object.worker (/Users/c050004/Documents/git/logger/node_modules/jest-haste-map/build/worker.js:120:18)
    at execFunction (/Users/c050004/Documents/git/logger/node_modules/jest-worker/build/workers/processChild.js:155:17)
    at execHelper (/Users/c050004/Documents/git/logger/node_modules/jest-worker/build/workers/processChild.js:139:5)
npm ERR! Test failed.  See above for more details.

Link to repl or repo (highly encouraged)

envinfo

  System:
    OS: macOS 10.15.3
    CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
  Binaries:
    Node: 10.16.3 - ~/.nvm/versions/node/v10.16.3/bin/node
    Yarn: 1.19.1 - /usr/local/bin/yarn
    npm: 6.14.4 - ~/Documents/git/logger/node_modules/.bin/npm
  npmPackages:
    jest: ^25.3.0 => 25.3.0 

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:17 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
SimenBcommented, Apr 26, 2020

I don’t think we need to make it configurable for now. Somebody can complain if they really need it, but I don’t really see a use case for tests in a VCS directory (while I can imagine use cases for tests in other hidden directories).

And yes, we only need to update the node crawler (which also has find in it)

1reaction
leonardovillelacommented, Apr 27, 2020

In the next days, I’ll update my PR to follow this approach.

Read more comments on GitHub >

github_iconTop Results From Across the Web

error: pathspec 'test-branch' did not match any file(s) known to git
When cloning a repo, only one local branch ( master , here) is created and checked out in the resulting clone, irrespective of...
Read more >
Configuring Jest
For example, with the following configuration jest will fail if there is less than 80% branch, line, and function coverage, or if there...
Read more >
Husky - Git hooks
Modern native Git hooks made easy. ... Husky is used by these awesome projects: ... Another case you may be in is if...
Read more >
Setting Up Jest - LearnHowToProgram.com
Make sure that you are referencing the code from the branch called 1_functioning_environment . This is the default branch, so running git clone......
Read more >
Beyond API testing with Jest | CircleCI
Jest is a JavaScript-based testing framework that lets you test both ... Next, you need to make some changes to the package.json file...
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