ssssota / doc-vitest

Documentation tests with Vitest
https://npmjs.com/vite-plugin-doctest
59 stars 0 forks source link

Add example for Nuxt #84

Open Rednas83 opened 2 months ago

Rednas83 commented 2 months ago

I would like to try it with nuxt.

Can the setup be done with nuxt.config.ts?

Tried:

import { doctest } from 'vite-plugin-doctest';
export default defineNuxtConfig({
  plugins: [doctest({ /* options */ })],
  test: {
    includeSource: [
      './src/**/*.[jt]s?(x)',
      './**/*.md', // You can disable markdown test by removing this line
    ],
  },
})

But it returns an error image

ssssota commented 2 months ago

If you want to use vitest at Nuxt project, you should put a vitest.config.ts (official document). And, you can configuration testing at vitest.config.ts.

Here is the example! https://stackblitz.com/edit/nuxt-doctest?file=vitest.config.ts,functions%2Fsome-function.ts

fyi: vite-plugin-doctest cannot test comment in .vue files.