Search code examples
reactjsrollupjsvitest

Vitest (v1.1.2) throws errors


After upgrading vitest to latest version (1.1.2) from v0.33.0 for my React project, I'm seeing the following errors when running tests

Error: Expected ';', '}' or <eof>
❯ error node_modules/rollup/dist/es/shared/parseAst.js:337:30
❯ nodeConverters node_modules/rollup/dist/es/shared/parseAst.js:2084:9
❯ convertNode node_modules/rollup/dist/es/shared/parseAst.js:969:12
❯ convertProgram node_modules/rollup/dist/es/shared/parseAst.js:960:48
❯ parseAstAsync node_modules/rollup/dist/es/shared/parseAst.js:2150:20
❯ ssrTransformScript node_modules/vite/dist/node/chunks/dep-R0I0XnyH.js:49846:15

Any ideas what's going on here?

NOTE:

  1. my React project is configured with Webpack instead of Vite due to legacy reasons and Vitest worked perfectly with it before on v0.33.0.
  2. Besides upgrading vitest, I also upgraded the following deps to their latest versions: @vitejs/plugin-react, @vitest/coverage-v8, @vitest/ui.

Solution

  • I eventually sorted this out and the solution is very classic: I had to remove the yarn.lock file and rebuild it by running "yarn" command again. I know it's not an optimal solution, but it works for now...