Skip to content

Commit c3f46aa

Browse files
committed
test: add unocss-vue-scoped
1 parent 50e157e commit c3f46aa

File tree

8 files changed

+564
-48
lines changed

8 files changed

+564
-48
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<template>
2+
<HelloUnoCSS />
3+
</template>
4+
5+
<script setup lang="ts">
6+
import HelloUnoCSS from './HelloUnoCSS.vue'
7+
</script>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<template>
2+
<div class="uno bg-green-200 text-purple">UnoCSS</div>
3+
</template>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { expect, test } from 'vitest'
2+
import {
3+
editFile,
4+
getBgColor,
5+
isServe,
6+
page,
7+
untilBrowserLogAfter,
8+
} from '~utils'
9+
10+
test.runIf(isServe)('regenerate CSS and HMR', async () => {
11+
const el = await page.$('.uno')
12+
expect(await getBgColor(el)).toBe('rgb(187, 247, 208)')
13+
14+
await untilBrowserLogAfter(
15+
() =>
16+
editFile('HelloUnoCSS.vue', (code) =>
17+
code.replace('bg-green-200', 'bg-red-200'),
18+
),
19+
[
20+
'[vite] hot updated: /HelloUnoCSS.vue',
21+
'[vite] hot updated: /HelloUnoCSS.vue?vue&type=style&index=0&scoped=468ceaae&lang.css',
22+
],
23+
false,
24+
)
25+
await expect.poll(() => getBgColor(el)).toMatch('rgb(254, 202, 202)')
26+
})
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<div id="app"></div>
2+
<script type="module">
3+
import { createApp } from 'vue'
4+
import App from './App.vue'
5+
6+
createApp(App).mount('#app')
7+
</script>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "@vitejs/test-unocss-vue-scoped",
3+
"private": true,
4+
"version": "0.0.0",
5+
"type": "module",
6+
"scripts": {
7+
"dev": "vite",
8+
"build": "vite build",
9+
"debug": "node --inspect-brk ../../packages/vite/bin/vite",
10+
"preview": "vite preview"
11+
},
12+
"dependencies": {
13+
"unocss": "^66.4.1",
14+
"vue": "catalog:"
15+
},
16+
"devDependencies": {
17+
"@types/node": "^22.16.5",
18+
"@vitejs/plugin-vue": "workspace:*"
19+
}
20+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { defineConfig, presetWind3 } from 'unocss'
2+
3+
export default defineConfig({
4+
presets: [presetWind3()],
5+
})
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { defineConfig } from 'vite'
2+
import vue from '@vitejs/plugin-vue'
3+
import UnoCSS from 'unocss/vite'
4+
5+
export default defineConfig({
6+
plugins: [vue(), UnoCSS({ mode: 'vue-scoped' })],
7+
build: {
8+
// to make tests faster
9+
minify: false,
10+
},
11+
})

0 commit comments

Comments
 (0)