Select the types of activity you want to include in your feed.
[READ-ONLY] Mirror of https://github.com/danielroe/nuxt-vitest. An vitest environment with support for testing code that needs a Nuxt runtime environment
···11-<h1 align="center">vitest-environment-nuxt</h1>
22-<p align="center">An in-development vitest environment with support for testing code that needs a Nuxt runtime environment.</p>
33-44-<p align="center">
11+# vitest-environment-nuxt
5263[![npm version][npm-version-src]][npm-version-href]
74[![npm downloads][npm-downloads-src]][npm-downloads-href]
85[![Github Actions][github-actions-src]][github-actions-href]
96[![Codecov][codecov-src]][codecov-href]
1071111-</p>
88+> A vitest environment for testing code that needs a [Nuxt](https://nuxt.com) runtime environment
1291313-> An in-development vitest environment with support for testing code that needs a Nuxt runtime environment
1010+- [✨ Changelog](https://github.com/danielroe/vitest-environment-nuxt/blob/main/CHANGELOG.md)
14111515-⚠️ This library is in active development and you should pin the patch version before using.
1212+> **Warning**
1313+> This library is in active development and you should pin the patch version before using.
16141717-## Quick Start
1515+## Installation
18161919-First install `vitest-environment-nuxt`:
1717+1. First install `vitest-environment-nuxt`:
20182119```bash
2222-yarn add --dev vitest-environment-nuxt
2323-2424-# or npm
2525-npm i -D vitest-environment-nuxt
2626-2727-# or pnpm
2820pnpm add -D vitest-environment-nuxt
2121+2222+# or
2323+yarn add --dev vitest-environment-nuxt
2424+npm i -D vitest-environment-nuxt
2925```
2626+2727+2. Then create a `vitest.config.mjs` with the following content:
2828+2929+```js
3030+import { defineConfigWithNuxtEnv } from 'vitest-environment-nuxt/config'
3131+3232+export default defineConfigWithNuxtEnv({
3333+ // any custom vitest config you require
3434+})
3535+```
3636+3737+That's it. Now when you run `vitest` your Nuxt environment will be available throughout your tests.
3838+3939+## 👉 Important notes
4040+4141+When you run your tests within `vitest-environment-nuxt`, they will be running in a [`happy-dom`](https://github.com/capricorn86/happy-dom) environment. Before your tests run, a global Nuxt app will be initialised (including, for example, running any plugins or code you've defined in your `app.vue`).
4242+4343+This means you should be take particular care not to mutate the global state in your tests (or, if you have, to reset it afterwards).
30443145## 💻 Development
3246···40544155Made with ❤️
42564343-Published under [MIT License](./LICENCE).
5757+Published under the [MIT License](./LICENCE).
44584559<!-- Badges -->
4660
+1-1
package.json
···11{
22 "name": "vitest-environment-nuxt",
33 "version": "0.2.0",
44- "description": "An in-development vitest environment with support for testing code that needs a Nuxt runtime environment.",
44+ "description": "An vitest environment with support for testing code that needs a Nuxt runtime environment.",
55 "repository": "danielroe/vitest-environment-nuxt",
66 "keywords": [
77 "nuxt",