vitest-dev / vitest

Next generation testing framework powered by Vite.

Home Page:https://vitest.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

执行 vitest 时报错 ast.body is not iterable

JZLeung opened this issue · comments

Describe the bug

尝试过删除package-lock.json和node_modules和运行 npm cache clean --force 后重新安装,仍旧报这个错误。

PS D:\vitest-dev> npm run test

> vitest-dev@0.1.0 test
> vitest


 DEV  v1.1.0 D:/vitest-dev


⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Unhandled Errors ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯

Vitest caught 1 unhandled error during the test run.
This might cause false positive tests. Resolve unhandled errors to make sure your tests are not affected.

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Unhandled Error ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
TypeError: ast.body is not iterable
 ❯ ssrTransformScript node_modules/vite/dist/node/chunks/dep-k5wXcrSr.js:54282:28
 ❯ loadAndTransform node_modules/vite/dist/node/chunks/dep-k5wXcrSr.js:53796:11
 ❯ ViteNodeServer._transformRequest node_modules/vite-node/dist/server.mjs:393:16
 ❯ ViteNodeServer._fetchModule node_modules/vite-node/dist/server.mjs:359:17
 ❯ MessagePort.<anonymous> node_modules/vitest/dist/vendor/index.cAUulNDf.js:60:20

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯

 Test Files  no tests
      Tests  no tests
     Errors  1 error
   Start at  14:19:34
   Duration  1.27s (transform 0ms, setup 0ms, collect 0ms, tests 0ms, environment 0ms, prepare 0ms)

Reproduction

https://stackblitz.com/edit/vitest-dev-vitest-ukkflo?file=package.json

System Info

System:
    OS: Windows 11 10.0.22631
    CPU: (16) x64 Intel(R) Core(TM) i7-10700 CPU @ 2.90GHz
    Memory: 7.93 GB / 31.78 GB
  Binaries:
    Node: 18.18.0 - C:\Program Files\nodejs\node.EXE
    npm: 9.8.1 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Chromium (122.0.2365.52)
    Internet Explorer: 11.0.22621.1

Used Package Manager

npm

Validations

Hello @JZLeung. Please provide a minimal reproduction using a GitHub repository or StackBlitz (you can also use examples). Issues marked with needs reproduction will be closed if they have no activity within 3 days.