question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unexpected Token in JSON error when running tests

See original GitHub issue

Describe 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:open
  • Created a year ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
zxch3ncommented, May 24, 2022

You can now use watch mode inside VS Code

0reactions
zxch3ncommented, Jun 18, 2022

Does test running work on pre-release version now?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found