You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
svelte/vitest.config.js

50 lines
1.2 KiB

import * as fs from 'node:fs';
import * as path from 'node:path';
import { configDefaults, defineConfig } from 'vitest/config';
const pkg = JSON.parse(fs.readFileSync('packages/svelte/package.json', 'utf8'));
export default defineConfig({
// We need both a plugin and an alias for some reason
resolve: {
alias: [
{
find: /^svelte\/?/,
customResolver: (id) => {
// For some reason this turns up as "undefined" instead of "svelte"
const exported = pkg.exports[id.replace('undefined', '.')];
if (!exported) return;
return path.resolve('packages/svelte', exported.browser ?? exported.default);
}
}
]
},
plugins: [
{
name: 'resolve-svelte',
resolveId(id) {
if (/^svelte\/?/.test(id)) {
const exported = pkg.exports[id.replace('svelte', '.')];
if (!exported) return;
return path.resolve('packages/svelte', exported.browser ?? exported.default);
}
}
}
],
test: {
dir: '.',
reporters: ['dot'],
include: [
'packages/svelte/tests/*/test.ts',
'packages/svelte/tests/runtime-browser/test-ssr.ts'
],
exclude: [...configDefaults.exclude, '**/samples/**'],
coverage: {
provider: 'v8',
reporter: ['lcov', 'html']
}
}
});