test(frontend): read theme source files with ?raw imports instead of node builtins

This commit is contained in:
Chris Scott committed 2026-10-05 17:15:21 +00:00
1 parent 9b405325c0
commit 33be4afeb7
3 files changed
+6 -19

No files matched your search

+1 -8
View File
@@ -1,6 +1,4 @@
import { readFileSync } from 'node:fs'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import indexHtml from '../../../index.html?raw'
import { beforeEach, describe, expect, it } from 'vitest'
import {
APPEARANCE_STORAGE_KEY,
@@ -9,11 +7,6 @@ import {
resolveColorThemeTokens,
} from './colorTheme'
const indexHtml = readFileSync(
path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../../index.html'),
'utf8',
)
function themeColorMeta(): string | null {
return document.querySelector('meta[name="theme-color"]')?.getAttribute('content') ?? null
}
+2 -11
View File
@@ -1,17 +1,8 @@
import { readFileSync } from 'node:fs'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
import indexCss from '../../index.css?raw'
import textPart from '../../components/message/TextPart.tsx?raw'
import { describe, expect, it } from 'vitest'
import { resolveColorThemeTokens } from './colorTheme'
const themeDir = path.dirname(fileURLToPath(import.meta.url))
const indexCss = readFileSync(path.resolve(themeDir, '../../index.css'), 'utf8')
const textPart = readFileSync(
path.resolve(themeDir, '../../components/message/TextPart.tsx'),
'utf8',
)
function countOccurrences(source: string, needle: string): number {
return source.split(needle).length - 1
}
+3
View File
@@ -16,6 +16,9 @@ export default defineConfig({
NODE_ENV: "test",
},
setupFiles: ["./src/test/setup.ts"],
css: {
include: [/[?&]raw(?:&|$)/],
},
include: ["src/**/*.test.{ts,tsx}"],
},
resolve: {