mirror of
https://github.com/vitest-dev/vitest.git
synced 2026-01-25 16:48:18 +00:00
docs: use example table
This commit is contained in:
parent
1fa7afc17b
commit
6d536ce88c
@ -118,13 +118,7 @@ vitest related /src/index.ts /src/hello-world.js
|
||||
|
||||
## Examples
|
||||
|
||||
- [Unit Testing](https://github.com/vitest-dev/vitest/tree/main/test/core)
|
||||
- [Vue Component Testing](https://github.com/vitest-dev/vitest/tree/main/examples/vue)
|
||||
- [React Component Testing](https://github.com/vitest-dev/vitest/tree/main/examples/react)
|
||||
- [Svelte Component Testing](https://github.com/vitest-dev/vitest/tree/main/examples/svelte)
|
||||
- [Lit Component Testing](https://github.com/vitest-dev/vitest/tree/main/examples/lit)
|
||||
- [Vitesse Component Testing](https://github.com/vitest-dev/vitest/tree/main/examples/vitesse)
|
||||
- [All examples](https://github.com/vitest-dev/vitest/tree/main/examples)
|
||||
[@@include](../../../examples/README.md)
|
||||
|
||||
## Projects using Vitest
|
||||
|
||||
|
||||
@ -85,3 +85,7 @@ main.home {
|
||||
border-color: var(--c-accent) !important;
|
||||
background-color: #90C32130 !important;
|
||||
}
|
||||
|
||||
th, td {
|
||||
border: 1px solid #8885;
|
||||
}
|
||||
|
||||
@ -1,7 +1,10 @@
|
||||
import fs from 'fs'
|
||||
import type { Plugin } from 'vite'
|
||||
import { defineConfig } from 'vite'
|
||||
import Components from 'unplugin-vue-components/vite'
|
||||
import Unocss from 'unocss/vite'
|
||||
import { presetAttributify, presetIcons, presetUno } from 'unocss'
|
||||
import { resolve } from 'pathe'
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [
|
||||
@ -23,6 +26,7 @@ export default defineConfig({
|
||||
}),
|
||||
],
|
||||
}),
|
||||
IncludesPlugin(),
|
||||
],
|
||||
|
||||
optimizeDeps: {
|
||||
@ -35,3 +39,20 @@ export default defineConfig({
|
||||
],
|
||||
},
|
||||
})
|
||||
|
||||
function IncludesPlugin(): Plugin {
|
||||
return {
|
||||
name: 'include-plugin',
|
||||
enforce: 'pre',
|
||||
transform(code, id) {
|
||||
let changed = false
|
||||
code = code.replace(/\[@@include\]\((.*?)\)/, (_, url) => {
|
||||
changed = true
|
||||
const full = resolve(id, url)
|
||||
return fs.readFileSync(full, 'utf-8')
|
||||
})
|
||||
if (changed)
|
||||
return code
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
# Examples
|
||||
|
||||
| Example | Source | Playground |
|
||||
|---|---|---|
|
||||
| `lit` | [GitHub](https://github.com/vitest-dev/vitest/tree/main/examples/lit) | [Play Online](https://stackblitz.com/github/vitest-dev/vitest/tree/main/examples/lit?terminal=test) |
|
||||
|
||||
@ -25,7 +25,7 @@ async function run() {
|
||||
|
||||
const table = `| Example | Source | Playground |\n|---|---|---|\n${data.filter(notNullish).map(i => `| \`${i.name}\` | [GitHub](${i.github}) | [Play Online](${i.stackblitz}) |`).join('\n')}`
|
||||
|
||||
await fs.writeFile(resolve(examplesRoot, 'README.md'), `# Examples\n\n${table}\n`, 'utf-8')
|
||||
await fs.writeFile(resolve(examplesRoot, 'README.md'), `${table}\n`, 'utf-8')
|
||||
}
|
||||
|
||||
run()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user