Skip to content

Commit

Permalink
test: add test
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa committed Sep 17, 2024
1 parent 8ab0dbe commit dceaaf3
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 0 deletions.
9 changes: 9 additions & 0 deletions playground/css-lightningcss/__tests__/root/root.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { expect, test } from 'vitest'
import { getBg, isBuild, page, viteTestUrl } from '~utils'

test('url dependency', async () => {
const css = await page.$('.url-dep')
expect(await getBg(css)).toMatch(
isBuild ? /ok-[-\w]+\.png/ : `${viteTestUrl}/ok.png`,
)
})
2 changes: 2 additions & 0 deletions playground/css-lightningcss/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"scripts": {
"dev": "vite",
"build": "vite build",
"dev:root": "vite --config ./vite.config-root.js dev",
"build:root": "vite --config ./vite.config-root.js build",
"debug": "node --inspect-brk ../../packages/vite/bin/vite",
"preview": "vite preview"
},
Expand Down
3 changes: 3 additions & 0 deletions playground/css-lightningcss/root/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<p>url() dependency</p>
<div class="url-dep"></div>
<script type="module" src="./main.js"></script>
1 change: 1 addition & 0 deletions playground/css-lightningcss/root/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import './url-dep.css'
Binary file added playground/css-lightningcss/root/ok.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions playground/css-lightningcss/root/url-dep.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.url-dep {
background-image: url('./ok.png');
background-size: cover;
width: 50px;
height: 50px;
border: 1px solid black;
}
7 changes: 7 additions & 0 deletions playground/css-lightningcss/vite.config-root.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { defineConfig } from 'vite'
import baseConfig from './vite.config'

export default defineConfig({
...baseConfig,
root: 'root',
})

0 comments on commit dceaaf3

Please sign in to comment.