support for unit testing in a nuxt environment
See original GitHub issueDescribe 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 https://github.com/vitest-dev/vitest/issues/2044#issuecomment-1251939691_
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.
Related: https://github.com/nuxt/framework/issues/2465 (auto-import issues when testing components)
issue description from https://github.com/nuxt/framework/issues/7672 - @tobiasdiez
Issue Analytics
- State:
- Created 2 years ago
- Reactions:21
- Comments:25 (9 by maintainers)
Top Results From Across the Web
Getting Started With Nuxt Testing [A Beginner's Guide]
Unit Testing : Unit testing is performed by developers to test the procedures or impacted functionalities. You can use many unit testing ......
Read more >Testing · Get Started with Nuxt
How to test your Nuxt application. ... In Nuxt 3, we have a rewritten version of @nuxt/test-utils . We support Vitest and Jest...
Read more >Introduction to Nuxt Test Utils - Reflect.run
Nuxt Test Utils is a test utility library for Nuxt.js for creating tests for Nuxt projects and modules. It offers several helpful methods...
Read more >Access `process.env` property when testing nuxt.js app with jest
On the other hand, calling require runs the code at the time it is required so the alternative is to refactor your test...
Read more >How to Test Nuxt Stores with Jest | by Brandon Aaskov | Medium
When you first install Nuxt, you have the option to install a test framework. When you do, it gives you a sample test…...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
For those who can’t see the status, I’m working on this issue at the moment - which I think is pretty important. Here’s a spoiler: https://twitter.com/danielcroe/status/1590490011501142017.
Just wanting to add that this is quite a crucial feature to have, because right now we can’t run component tests in nuxt3.
Vitest also doesn’t know about the magic auto-imports, so I think it would be nice if Nuxt3 exposed a method that we can call in vitest for this.
Edit: I’ve found that the
unplugin-auto-import
plugin works well with providing its own vite config to vitest.