css-lightningcss.spec.ts — vite Source File
Architecture documentation for css-lightningcss.spec.ts, a typescript file in the vite codebase. 2 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 1f38999b_6d67_b745_6db8_24433610327e["css-lightningcss.spec.ts"] a340ba46_b2b7_3048_3bb3_6907a74c8464["vitest"] 1f38999b_6d67_b745_6db8_24433610327e --> a340ba46_b2b7_3048_3bb3_6907a74c8464 d3fd5575_295b_d6be_24dd_62d277645dc9["~utils"] 1f38999b_6d67_b745_6db8_24433610327e --> d3fd5575_295b_d6be_24dd_62d277645dc9 style 1f38999b_6d67_b745_6db8_24433610327e fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import { expect, test } from 'vitest'
import {
editFile,
findAssetFile,
getBg,
getColor,
isBuild,
page,
viteTestUrl,
} from '~utils'
// note: tests should retrieve the element at the beginning of test and reuse it
// in later assertions to ensure CSS HMR doesn't reload the page
test('linked css', async () => {
const linked = await page.$('.linked')
const atImport = await page.$('.linked-at-import')
expect(await getColor(linked)).toBe('blue')
expect(await getColor(atImport)).toBe('red')
if (isBuild) return
editFile('linked.css', (code) => code.replace('color: blue', 'color: red'))
await expect.poll(() => getColor(linked)).toBe('red')
editFile('linked-at-import.css', (code) =>
code.replace('color: red', 'color: blue'),
)
await expect.poll(() => getColor(atImport)).toBe('blue')
})
test('css import from js', async () => {
const imported = await page.$('.imported')
const atImport = await page.$('.imported-at-import')
expect(await getColor(imported)).toBe('green')
expect(await getColor(atImport)).toBe('purple')
if (isBuild) return
editFile('imported.css', (code) => code.replace('color: green', 'color: red'))
await expect.poll(() => getColor(imported)).toBe('red')
editFile('imported-at-import.css', (code) =>
code.replace('color: purple', 'color: blue'),
)
await expect.poll(() => getColor(atImport)).toBe('blue')
})
test('css modules', async () => {
const imported = await page.$('.modules')
expect(await getColor(imported)).toBe('turquoise')
expect(await imported.getAttribute('class')).toMatch(/\w{6}_apply-color/)
if (isBuild) return
editFile('mod.module.css', (code) =>
code.replace('color: turquoise', 'color: red'),
)
await expect.poll(() => getColor(imported)).toBe('red')
})
test('inline css modules', async () => {
const css = await page.textContent('.modules-inline')
expect(css).toMatch(/\._?\w{6}_apply-color-inline/)
})
test.runIf(isBuild)('minify css', async () => {
// should keep the rgba() syntax
const cssFile = findAssetFile(/index-[-\w]+\.css$/)
expect(cssFile).toMatch('rgba(')
expect(cssFile).not.toMatch('#ffff00b3')
})
test('css with external url', async () => {
const css = await page.$('.external')
expect(await getBg(css)).toMatch('url("https://vite.dev/logo.svg")')
})
test('nested css with relative asset', async () => {
const css = await page.$('.nested-css-relative-asset')
expect(await getBg(css)).toMatch(
isBuild ? /ok-[-\w]+\.png/ : `${viteTestUrl}/ok.png`,
)
})
test('aliased asset', async () => {
const bg = await getBg('.css-url-aliased')
expect(bg).toMatch('data:image/svg+xml,')
})
test('preinlined SVG', async () => {
expect(await getBg('.css-url-preinlined-svg')).toMatch(
/data:image\/svg\+xml,.+/,
)
})
Dependencies
- vitest
- ~utils
Source
Frequently Asked Questions
What does css-lightningcss.spec.ts do?
css-lightningcss.spec.ts is a source file in the vite codebase, written in typescript.
What does css-lightningcss.spec.ts depend on?
css-lightningcss.spec.ts imports 2 module(s): vitest, ~utils.
Where is css-lightningcss.spec.ts in the architecture?
css-lightningcss.spec.ts is located at playground/css-lightningcss/__tests__/css-lightningcss.spec.ts (directory: playground/css-lightningcss/__tests__).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free