ssssota / doc-vitest

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

Add example for Nuxt #84

Closed Rednas83 closed 3 weeks ago

Rednas83 commented 4 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 4 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.