question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

support for unit testing in a nuxt environment

See original GitHub issue

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 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:open
  • Created 2 years ago
  • Reactions:21
  • Comments:25 (9 by maintainers)

github_iconTop GitHub Comments

17reactions
danielroecommented, Dec 1, 2022

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.

8reactions
TheDutchCodercommented, Aug 24, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found