-
-
Notifications
You must be signed in to change notification settings - Fork 425
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
jest can't find babel when i'm using gitDir #158
Comments
I'm not sure how this can cause this issue. Probably a way how Jest resolves |
When i'm using the following option in my jest.json jest finds babel-jest:
the default for this in jest is:
But now every other option in my jest.json points at the gitFolder and not the subfolder gui. Correct me if i'm wrong: I think a general problem with "gitDir" is, that the linters will be executed in the gitDir and not in the frontend-app (npm project). |
AFAIK executables should be located relative to |
I made another test to isolate the problem. I put the jest config in my package.json, so that i don't need the config-parameter and removed every linting tool, but jest.
The result is that jest can't find my config at all:
|
Can you add |
Can you create a GH repo with this setup so I can play around with it? |
The idea to call a npm-script instead of jest directly was a good one. It's working =D |
Great. It would be still good to get to the root cause so if you can invest some time into it it would be great! |
https://github.com/bmsuseluda/lintStagedJestTest/tree/master/gui |
I believe this line makes it behave like this: https://github.com/okonet/lint-staged/blob/master/src/runScript.js#L14 |
hi @bmsuseluda , i don't know if the issue still persists, but i'm not getting the problem by changing the included test and running |
Hi @DeFuex, |
Hi @okonet thanks for the commit. In my opinion it's better to reverse the algorithm from |
@bmsuseluda yeah, im a little bit tired today, seeing the issue now. had some other difficulties 😄 |
@bmsuseluda good idea! Do you or @DeFuex mind creating a PR for it? I'd add a long-ish comment explaining why it's needed. This should go away when #75 is done (if it's even possible, I still don't know) |
@okonet thanks, i will do it tomorrow. |
Inverses logic of checking for "not equal to `npm`", instead check that binary to run is equal to `git` (and accounting for absolute paths). This means that commands besides `npm` will also run in CWD instead of `gitDir`. Closes lint-staged#158
* change npm to git since gitDir is only used for git executables * fix(gitDir): `gitDir` should only be applied when using `git` binary Inverses logic of checking for "not equal to `npm`", instead check that binary to run is equal to `git` (and accounting for absolute paths). This means that commands besides `npm` will also run in CWD instead of `gitDir`. Closes #158
Hello okonet,
thank you for your great work.
I'm trying to use jest with lint staged, but when i'm using the "gitDir" option jest can't find babel-jest and so every test fails.
My config:
My folder structure:
gitFolder -> gui (frontend-app)
^^^^^^ SyntaxError: Unexpected token import at transformAndBuildScript (gui/node_modules/jest-runtime/build/transform.js:320:12)
I think the problem is that jest can't find babel-jest, because of the "gitDir"-option and so can't transform the import statement.
When i'm using jest without lint-staged it's working like a charm.
lint-staged: 3.4.0
jest: 19.0.2
babel-jest: 19.0.0
husky: 0.13.3
I hope you've got an idea where the problem comes from.
Thank you
The text was updated successfully, but these errors were encountered: