Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
"Jest encountered an unexpected token" in vscode-jest output, working everywhere else #415
Steps to Reproduce
Clone the repro repo.
Observe that the test passes. Now open the
Relevant Debug Info
I enabled debug output and opened dev tools. I found that (for one permutation of pathToJest and pathToConfig anyway) the following command was being logged:
This command (and all other commands logged in dev tools) execute correctly (tests pass, no errors) from a terminal.
I could see this being a duplicate of this bug or this bug - apologies for the churn if so, but I'd still like to know definitely if it is the same issue as one of these and if so what we can do to help resolve it.
There appears to be some disconnect between
Thank you for your time and effort.
I'm having a very similar issue. I can see the command it says it's running in the debug output, and if I run that myself in a terminal it's fine. But when it runs from vscode it doesn't seem to be running babel properly as it starts throwing unexpected token errors just like @ayan4m1's example.
I am using vue 2.5 with jest 23.6 and vscode 1.30.1 with latest extension.
From a terminal I can get a successful jest run with any of the following variants
I tested different settings for
So after restarting everything today, my tests stopped running in console as well from any of the above variants!
I discovered that jest keeps a temporary 'jest' folder which caches the transpilation results! The implication of this is that if vscode-jest runs with the wrong config, then it will cache the wrong results and not be able to recover until the cache is cleared. The converse is also true, if I had a successful run with
You can find the cache in a 'jest' folder here which you can clear by deleting it:
I think you can also use this built in flag to clear it, but I didn't try it:
So the solution for me was to change my
Thanks for taking the time to reply @JDeuce - originally, I did try clearing the Jest cache I knew about at
In the same directory,
If I got something wrong, please let me know.