Skip to content

support for unit testing in a nuxt environment #349

@aseidma

Description

@aseidma

Describe the feature

Unit testing (e.g. [parts of ]composables or server functions) doesn't require a full built of nuxt.

Originally posted by @pi0 in vitest-dev/vitest#2044 (comment)

We plan to support also unit testing with nuxi test but properly in a Nuxt environment. Exposing vite config only is not enough for doing that and in past similar approach made lots of headaches for testing in Nuxt 2. However, probably will expose as a @nuxt/kit utility anyway as an alternative to current usage that needs replicating vite config for aliases.

### Tasks
- [x] use `nuxt-vitest` internally whilst improving test suite + fixing issues
- [x] link to `nuxt-vitest` and improve its docs
- [x] merge `nuxt-vitest` into `@nuxt/test-utils`

Related: https://github.com/nuxt/nuxt.js/issues/13077 (auto-import issues when testing components)

issue description from nuxt/nuxt#14972 - @tobiasdiez

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions