Skip to content

[Bug]: Vitest Astro fails at running Storybook tests #16275

Description

@SalahAdDin

Astro Info

Astro                    v6.1.5
Node                     v24.14.1
System                   Linux (x64)
Package Manager          pnpm
Output                   static
Adapter                  none
Integrations             none

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

So, we implemented Storybook vitest runner for our Astro components.

Running the specific project for Storybook, we get the following issue:

> [email protected] test:storybook /home/LuisAlaguna/Projects/central-mosque-bogota/frontend
> vitest --project=storybook

(node:22877) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 change
 listeners added to [FSWatcher]. MaxListeners is 10. Use emitter.setMaxListeners() to increase limit                                                                                          (Use `node --trace-warnings ...` to show where the warning was created)

 DEV  v4.1.3 /home/LuisAlaguna/Projects/central-mosque-bogota/frontend

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ 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: Cannot read properties of undefined (reading 'wrapDynamicImport')
 ❯ getPackageManager node_modules/.pnpm/[email protected]_@[email protected][email protected]_lightningcss@
[email protected][email protected][email protected]/node_modules/astro/dist/cli/info/core/get-package-manager.js:16:5                                                                                 14|       const { PnpmPackageManager } = await import("../infra/pnpm-package-manager.js");
     15|       return new PnpmPackageManager({ commandExecutor });
     16|     }
       |     ^
     17|     case "npm": {
     18|       const { NpmPackageManager } = await import("../infra/npm-package-manager.js");
 ❯ createAstroServerApp node_modules/.pnpm/[email protected]_@[email protected][email protected]_lightningc
[email protected][email protected][email protected][email protected]/node_modules/astro/dist/vite-plugin-app/createAstroServerApp.js:27:28                                                                      ❯ createHandler node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]
[email protected][email protected][email protected]/node_modules/astro/dist/vite-plugin-astro-server/plugin.js:36:35                                                                                  ❯ BasicMinimalPluginContext.configureServer node_modules/.pnpm/[email protected]_@[email protected]_
[email protected][email protected][email protected][email protected][email protected]/node_modules/astro/dist/vite-plugin-astro-server/plugin.js:40:51                                                      ❯ _createServer node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected].
[email protected]/node_modules/vite/dist/node/chunks/config.js:25606:86                              ❯ Object.createBrowserServer [as serverFactory] node_modules/.pnpm/@[email protected]_vite@
7.3.2_@[email protected][email protected][email protected][email protected][email protected]/node_modules/@vitest/browser/dist/index.js:7865:15                                                            ❯ node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@vitest+
coverage-v8@4._6945d2656c5ab35fc9b6b2aa85a5bf98/node_modules/vitest/dist/chunks/cli-api.CaPRsymo.js:10864:19                                                                                   ❯ node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@vitest+
coverage-v8@4._6945d2656c5ab35fc9b6b2aa85a5bf98/node_modules/vitest/dist/chunks/cli-api.CaPRsymo.js:10875:3                                                                                    ❯ node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@vitest+
coverage-v8@4._6945d2656c5ab35fc9b6b2aa85a5bf98/node_modules/vitest/dist/chunks/cli-api.CaPRsymo.js:10983:22                                                                                   ❯ node_modules/.pnpm/[email protected]_@[email protected]_@[email protected]_@vitest+
coverage-v8@4._6945d2656c5ab35fc9b6b2aa85a5bf98/node_modules/vitest/dist/chunks/cli-api.CaPRsymo.js:2438:4                                                                                    
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯


 Test Files  no tests
      Tests  no tests
     Errors  1 error
   Start at  00:09:12
   Duration  468ms (transform 0ms, setup 0ms, import 0ms, tests 0ms, environment 0ms)

 FAIL  Tests failed. Watching for file changes...
       press h to show help, press q to quit
Cancelling test run. Press CTRL+c again to exit forcefully.

 ELIFECYCLE  Command failed with exit code 130.

What's the expected result?

It should not have any issues running the test project.

Link to Minimal Reproducible Example

https://github.com/SalahAdDin/central-mosque-bogota/tree/main/frontend

Participation

  • I am willing to submit a pull request for this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    - P3: minor bugAn edge case that only affects very specific usage (priority)pkg: astroRelated to the core `astro` package (scope)triage: fix verifiedReporter confirmed the triage bot fix works

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions