-
Notifications
You must be signed in to change notification settings - Fork 668
Vue + Jest + Typescript Unexpected reserved word 'let' and Jest encountered an unexpected token #1358
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
Comments
Ok, I got a similar error (but not about
This seems to be the problem, specifically
And it should be okay. It seemed to think
I don't think it's a bug in vue-test-utils. |
Going to close this one for now - let me know if you disagree with this, @Maniumn . If it helps, there is a tslint rule to prevent using |
This is not a solution. My example is a little code from big project. In my project there are everywhere problems with test, let, JSX, babel ... Something is complettly wrong with vue class based and tests with jest. |
@Maniumn , can you provide a repro demonstrating the problems with I was able to get your reproduction running correctly by using the If you have an alternative failing repro I can pull down, I'm happy to reopen this issue until we have a fix. "Something is completely wrong with class based tests with Jest" is not enough to allow me to troubleshoot your issue. |
This is a problem plaguing me as well |
@lmiller1990 I'm not using jsx anywhere in my project, and I don't want to. Whenever I run jest on code using |
My question: is there any way to use Vue without ANY jsx at all, in such a way that I can use Thanks so much for your help |
You are using Vue 2 (not Vue 3 right) + Vue CLI? The obvious work-around is just to use |
Yeah, that is the obvious workaround I'll do if this doesn't get answered. But I was wondering if I could totally disable React and jsx in the parser, so there is no ambiguity |
Most likely it is possible to disable JSX, you will need to play around with the Vue CLI config. This is not really a VTU specific problem but Jest + tooling. There is likely some magic configuration that will allow this to work but for now I would recommend just never using the If I have some time I might try figure this out but I cannot promise I can spend time on this with other issues taking priority. Let me know if you do get it working, though, I am sure someone wants this. |
Thank you. The easy solution is simply to enable eslint. I have went through everything I could to get rid of all jsx references to no avail. So I will use the eslint rule. :( |
Thanks @lmiller1990 its working. In my case Change to |
Why not just do lookupContainer: HTMLElement = this.$refs.lookupResult as HTMLElement; ? |
I get different errors by unit test for working code. With babel installed "Unexpected reserved word 'let'" and without babel installed "Jest encountered an unexpected token". What do I do wrong?
Version
1.0.0-beta.29
Reproduction links
https://github.com/Maniumn/vue-typescript-babel-unit-test
https://github.com/Maniumn/vue-typescript-no-babel-unit-test
Steps to reproduce
git clone
npm i
npm run test:unit
What is expected?
Test passed
What is actually happening?
Errors: Unexpected reserved word 'let' and Jest encountered an unexpected token
The text was updated successfully, but these errors were encountered: