vscode icon indicating copy to clipboard operation
vscode copied to clipboard

Unexpected Token in JSON error when running tests

Open charliedavison opened this issue 3 years ago • 6 comments

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

charliedavison avatar May 24 '22 09:05 charliedavison

This extension will invoke the vitest command to write to the file and then read the result from the file. This behavior will be changed in the near future, to read results directly from vitest --api. It will fix this issue

zxch3n avatar May 24 '22 09:05 zxch3n

@zxch3n Great, thank you - any way around it for now or just need to wait for the change?

charliedavison avatar May 24 '22 10:05 charliedavison

Does watch mode work for you?

zxch3n avatar May 24 '22 10:05 zxch3n

In the CLI yes its fine

charliedavison avatar May 24 '22 10:05 charliedavison

You can now use watch mode inside VS Code

zxch3n avatar May 24 '22 10:05 zxch3n

Does test running work on pre-release version now?

zxch3n avatar Jun 18 '22 13:06 zxch3n