Unexpected Token in JSON error when running tests
See original GitHub issueDescribe the bug @testing-library/react: 13.1.1 vitest: 0.12.9
When running any test from the plugin the run fails with “SyntaxError: Unexpected token in JSON at position 52”.
From the output It appears that the plugin is trying to write invalid JSON to a file and then read it back
JSON report written to /var/folders/nh/f9txjbr50mg66b89_51z2d2w0000gn/T/vitest-report-eqem9.json
JUNIT report written to /var/folders/nh/f9txjbr50mg66b89_51z2d2w0000gn/T/vitest-report-eqem9.json
Done in 1.09s.
Run test failed
SyntaxError: Unexpected token
in JSON at position 52
Issue Analytics
- State:
- Created a year ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
What Is JSON and How to Handle an “Unexpected Token” Error
The first thing to do in this situation is to confirm where the error is happening exactly. To ensure the error happens on...
Read more >How to Fix SyntaxError: Unexpected token < in JSON at ...
In this case the error is thrown when response.json() tries to run and fails to parse the data from the server as JSON....
Read more >Error when unit testing: "Uncaught (in promise) SyntaxError
The error Unexpected token ... in JSON at position 1 actually means that JSON.parse was applied to something that is not valid JSON...
Read more >Troubleshoot 'Uncaught SyntaxError: Unexpected token u in ...
The 'Uncaught SyntaxError: Unexpected token u in JSON at position 0' error is caused when the client has been asked to execute JSON.parse() ......
Read more >Unexpected token < in JSON at position 0 - Dave Ceddia
The exact text of this error will differ depending on what the server returned. The token and the position may vary, but the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

You can now use watch mode inside VS Code
Does test running work on pre-release version now?