vite-plugin-nuxt-test

Vite plugin to test a Nuxt 3 application.
975 8
Install
npm install vite-plugin-nuxt-test
Latest Version:0.0.10
License:MIT
Last Updated:Nov 27, 2022
Links: GitHub  ·  npm
Maintainer: yassidevteam

Nuxt + Vitest = ☀️

This is a simple plugin that will add some basic configuration for Vitest to run properly inside your Nuxt 3 application (autoimports, aliases, etc.).

Installation

// vitest.config.ts
import { defineConfig } from 'vitest/config'
import NuxtVitest from 'vite-plugin-nuxt-test'

export default defineConfig({
    plugins: [NuxtVitest()],
    test: {
        // Your own configuration
    }
})

Usage

You may then use Vitest to test your composables without worrying about auto-imported methods.

// composables/useBar.ts
export function useBar() {
    return 'bar'
}
// composables/useFoo.ts
export function useFoo() {
    return useBar() + '-foo'
}
import { describe, test } from 'vitest'

describe('useFoo', () => {
    it ('should not need to be imported', () => {
        expect(useFoo).toBeDefined() // ✅
    })

    it ('should auto-import useBar as well', () => {
        expect(useFoo()).toBe('bar-foo') // ✅
    })
})

Related Packages

unplugin-vue-prop

Add import define props type support for Vue3 script-setup and lang is typescrip...

1,105 2
@storybook-vue/nuxt

Storybook addon for Nuxt and Vite

2,665,088 490
@nuxtjs/storybook

Storybook module for Nuxt

2,341,848 489
@storybook-nuxt/framework

Storybook for Nuxt and Vite: Develop Vue3 components in isolation with Hot Reloa...

792 132
@storybook-nuxt/monorepo

Storybook for Nuxt and Vite: Develop Vue3 components in isolation with Hot Reloa...

297

Version History

Version Released License
0.0.10 MIT
0.0.9 MIT
0.0.8 MIT
0.0.7 MIT
0.0.6 MIT