mirror of
https://github.com/TriliumNext/Trilium.git
synced 2026-10-12 02:09:59 +00:00
index.ts had no spec at all: ensureMimeTypes, highlight and loadTheme were entirely untested, leaving the package at 62% lines and 10% branches. Adds index.spec.ts covering mime registration and dedup, disabled and definition-less entries, both null paths of highlight(), and the loadTheme style-element lifecycle including removal on "none". Note the tests address highlight() by the CKEditor-normalised mime (application/json -> application-json), because that is what ensureMimeTypes keys on and what callers pass. themes.ts gains coverage for getThemeVariant plus a loop invoking all 84 theme loaders. That asserts module shape only — Vitest resolves ?raw CSS to an empty string, so there is no text to check; a mistyped path is caught earlier still, when Vite fails to transform themes.ts. 100% lines, branches and functions, enforced by coverage thresholds. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
53 lines
1.7 KiB
TypeScript
53 lines
1.7 KiB
TypeScript
|
|
import { defineConfig } from 'vite';
|
|
|
|
export default defineConfig(() => ({
|
|
root: __dirname,
|
|
cacheDir: '../../node_modules/.vite/packages/highlightjs',
|
|
plugins: [],
|
|
build: {
|
|
outDir: './dist',
|
|
emptyOutDir: true,
|
|
reportCompressedSize: true,
|
|
commonjsOptions: {
|
|
transformMixedEsModules: true,
|
|
},
|
|
lib: {
|
|
// Could also be a dictionary or array of multiple entry points.
|
|
entry: 'src/index.ts',
|
|
name: 'highlightjs',
|
|
fileName: 'index',
|
|
// Change this to the formats you want to support.
|
|
// Don't forget to update your package.json as well.
|
|
formats: ['es' as const]
|
|
},
|
|
rollupOptions: {
|
|
// External packages that should not be bundled into your library.
|
|
external: []
|
|
},
|
|
},
|
|
test: {
|
|
'watch': false,
|
|
'globals': true,
|
|
'environment': "happy-dom",
|
|
'include': ["src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}"],
|
|
'reporters': [
|
|
"default",
|
|
["junit", { outputFile: "./test-output/vitest/junit.xml", addFileAttribute: true }]
|
|
],
|
|
'coverage': {
|
|
'thresholds': {
|
|
'lines': 100,
|
|
'functions': 100,
|
|
'branches': 100,
|
|
'statements': 100
|
|
},
|
|
'reportsDirectory': './test-output/vitest/coverage',
|
|
'provider': 'v8' as const,
|
|
'include': ["src/**/*.{ts,tsx}"],
|
|
'exclude': ["**/*.{test,spec}.{ts,mts,cts,tsx,js,jsx}", "**/*.d.ts"],
|
|
'reporter': ["text", "lcov"],
|
|
}
|
|
},
|
|
}));
|