Jest watch fails when used in a git monorepo containing a sub-project named ui - and a default branch called ui.
jest --watch fails with:
fatal: ambiguous argument 'ui': both revision and filename
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
Check out the monorepo and run npx jest --watch
Jest should start watching the files. Instead, it appears that the 'jest-changed-files' tool does not handle cases where the default branch and test root have the same name.
If I run git diff commands from the ui folder it is fine - so it's possible that a cwd before running git commands might fix it?
https://github.com/nicthemighty/jest-watch
System:
OS: macOS 10.15.4
CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
Binaries:
Node: 10.18.1 - ~/.nvm/versions/node/v10.18.1/bin/node
Yarn: 1.21.1 - ~/.nvm/versions/node/v10.18.1/bin/yarn
npm: 6.13.6 - ~/.nvm/versions/node/v10.18.1/bin/npm
npmPackages:
jest: ^26.0.1 => 26.0.1
I encountered this error too. In my case, the branch with the same name as the subdirectory was _not_ my default branch and deleting the branch worked around the issue.
Most helpful comment
I encountered this error too. In my case, the branch with the same name as the subdirectory was _not_ my default branch and deleting the branch worked around the issue.