Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unhelpful error message when jest --watch is run outside of git repository #4419

Closed
foxbunny opened this issue Sep 4, 2017 · 15 comments
Closed

Comments

@foxbunny
Copy link

foxbunny commented Sep 4, 2017

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

What is the current behavior?
When jest --watch is executed inside a non-git folder the following exception is raised:

Determining test suites to run...Error: This promise must be present when running with -o.
    at /path/to/node_modules/jest-cli/build/search_source.js:192:17
    at next (native)
    at step (/path/to/node_modules/jest-cli/build/search_source.js:20:362)
    at /path/to/node_modules/jest-cli/build/search_source.js:20:592
    at /path/to/node_modules/jest-cli/build/search_source.js:20:273
    at SearchSource.getTestPaths (/path/to/node_modules/jest-cli/build/search_source.js:204:10)
    at /path/to/node_modules/jest-cli/build/run_jest.js:45:31
    at next (native)
    at step (/path/to/node_modules/jest-cli/build/run_jest.js:24:380)
    at /path/to/node_modules/jest-cli/build/run_jest.js:24:540

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.

  • Set up a new project (or clone existing one)
  • Make sure .git folder is not present (removed)
  • Run jest

What is the expected behavior?
A more helpful message as to why jest failed.

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

  • Jest v21.0.1
  • NodeJS v6.10.1
@cpojer
Copy link
Member

cpojer commented Sep 4, 2017

That's a bug! cc @rogeliog @aaronabramov

@kelcecil
Copy link

kelcecil commented Sep 4, 2017

I've run into the same issue with the follow configuration:

  • Jest v21.0.1
  • Node v8.4.0
  • npm v5.4.0
  • Mac OS 10.12.4

I did a little playing with versions to deduce where the problem may have started. Downgrading to Jest v21.0.0 leaves me with the same problem, and the same workaround as above solves the issue. I'm able to run jest --watch with no errors when using Jest v20.0.4 and missing a .git directory in my project.

@thiagohora
Copy link

I've run into the same issue with the follow configuration:

Jest v21.0.1
Node v7.10.0
npm 4.2.0
Linux mint 18.2

running: jest --watch

@rogeliog
Copy link
Contributor

rogeliog commented Sep 8, 2017

I'm also able to repro it, I think it was introduced here

@Thomblin
Copy link

Thomblin commented Sep 8, 2017

Same issue here

Jest 21.0.1
Node 8.1.2
npm 5.0.3

@rogeliog
Copy link
Contributor

rogeliog commented Sep 8, 2017

cc: @aaronabramov

@15Dkatz
Copy link

15Dkatz commented Sep 9, 2017

Downgrading back to jest cli version 20.0.4 seems to be a temporary solution:

npm install [email protected] --save or (I believe):yarn add [email protected]

@Thomblin
Copy link

Thomblin commented Sep 9, 2017

@15Dkatz thx, that helped

@aaronabramov
Copy link
Contributor

@rogeliog it seems like it happens because onlyChanged is set to true here https://github.com/facebook/jest/blob/master/packages/jest-cli/src/lib/update_global_config.js#L53-L56

and if onlyChanged is true, we assume that we're in a git/hg repo and try to get the list of changed files, which is not possible if we're not in git.

Can we just remove this assignment from watch mode? is this config option is used for anything else then getting changed files from hg/git?

@TroySchmidt
Copy link

Thanks for the point out there @aaronabramov. I ended up changing to --watchAll which helps to circumvent this issue.

@b-asaf
Copy link

b-asaf commented Oct 15, 2017

My configuration is:

...
"react": "16.0.0-alpha.12",
"react-native": "0.45.1",
"react-native-camera": "^0.10.0",
"babel-jest": "21.2.0",
"babel-preset-react-native": "4.0.0",
"jest": "21.2.1",
...

2 possibles solutions (that I found):

  1. I downgraded back to V20.0.4.
  2. instead of 'yarn test --watch' I am using 'yarn test --watchAll' (as @TroySchmidt suggested)

@ziolekjj
Copy link

it works when i use --watchAll, but when i played around with filters (pattern mode) and after that i clicked "c" to clear filters i had the same error again.

cpojer pushed a commit that referenced this issue Nov 3, 2017
* Use watchAll fallback for non git/hq projects (#4419)

* use stdout instead of console

* print error when no hq/git project instead of changing arguments

* add integration tests for watch arg requires hq or git
@johnnyjanzen
Copy link

johnnyjanzen commented Nov 6, 2017

Same issue:

Jest: 21.2.1
Yarn: 1.3.2
Node: 8.9.0
React Native: 0.49.5

Adding a git repo to project folder is a fix.

@SimenB
Copy link
Member

SimenB commented Nov 6, 2017

Fixed in #4737 (not released)

@cpojer cpojer closed this as completed Nov 7, 2017
sesigl added a commit to sesigl/jest that referenced this issue Nov 8, 2017
cpojer pushed a commit that referenced this issue Nov 9, 2017
* Use watchAll fallback for non git/hq projects (#4419)

* use stdout instead of console

* print error when no hq/git project instead of changing arguments

* add integration tests for watch arg requires hq or git

* check watch flag and repos to find out if watch is not possible

* tests show error message when no vcs and watch is set

* Use watchAll fallback for non git/hq projects (#4419)

* use stdout instead of console

* check watch flag and repos to find out if watch is not possible

* tests show error message when no vcs and watch is set

* make watch check earlier to improve performance when watch is false
PeterTognola added a commit to PeterTognola/MarkdownDocuments that referenced this issue Feb 12, 2018
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests