-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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 does not transpile code correctly when it's not runed manually. #7212
Comments
I cannot reproduce this. I'm also on mac... (btw, when using jest in a commit hook a good idea might be to use something like |
Just to add my two cents. Have the same problem when running from msysgit. Run fine when using cmd which is a bummer but probably not related to jest or babel-jest at all. |
This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 14 days. |
I have the same problem on VSCode with WSL 2. I have a pre-push git hook setup to run npm test which uses jest. As a note, I'm using ES6 modules for my code and have the following config option to make jest support the import statements: |
This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 30 days. |
This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one. |
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. |
🐛 Bug Report
Hello!
My set up is Babel 7 with TypeScript and the jest.config's transform property is set to
babel-jest
. The reason why I'm not usingts-jest
is because I want to transpile the code with Babel so I can use the preval plugin.This works great when I when I manually runs
yarn test
, it'll transpile the code according to the .babelrc config and run the tests without any errors or failures. The problem arrived whenyarn test
isn't runed by me directly.I have a git hook with Husky to have it run
yarn test
with thepre-commit
hook. What happens is whenever a commit happends, it'll runyarn test
and Jest will fail to transpile the code. The output logs will be filled withJest encountered an unexpected token
, and it seems like Jest ignores the Babel config entirely when the command isn't executed directly by me.It also seems to be a connection to this and the errors I get when the VS Code Extention vscode-jest is being runed in the background.
They do not interfere with each other, tried without the plugin and the same issue is still present.
To Reproduce
I've provided a repo that have this set up and issues.
For the git hook:
For vscode-jest extention:
Expected behavior
Since it works with me manually running
yarn test
and it'll transpile and tests correctly, the other cases should do that aswell, i.e. anything else than me running the jest command.Link to repl or repo (highly encouraged)
Link to the repo
Run
npx envinfo --preset jest
Paste the results here:
The text was updated successfully, but these errors were encountered: