2023-11-10 15:48:23 +01:00
|
|
|
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({
|
|
|
|
resolve: {
|
|
|
|
alias: [
|
|
|
|
{
|
|
|
|
find: /^svelte\/?/,
|
2024-02-06 16:09:51 +01:00
|
|
|
customResolver: (id, importer) => {
|
|
|
|
// For some reason this turns up as "undefined" instead of "svelte/"
|
|
|
|
const exported = pkg.exports[id === 'undefined' ? '.' : id.replace('undefined', './')];
|
2023-11-10 15:48:23 +01:00
|
|
|
if (!exported) return;
|
|
|
|
|
2024-02-06 16:09:51 +01:00
|
|
|
// When running the server version of the Svelte files,
|
|
|
|
// we also want to use the server export of the Svelte package
|
|
|
|
return path.resolve(
|
|
|
|
'packages/svelte',
|
|
|
|
importer?.includes('_output/server')
|
|
|
|
? exported.default
|
|
|
|
: exported.browser ?? exported.default
|
|
|
|
);
|
2023-11-10 15:48:23 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
test: {
|
|
|
|
dir: '.',
|
|
|
|
reporters: ['dot'],
|
|
|
|
include: [
|
2024-01-31 03:22:47 +01:00
|
|
|
'packages/svelte/**/*.test.ts',
|
2023-11-10 15:48:23 +01:00
|
|
|
'packages/svelte/tests/*/test.ts',
|
|
|
|
'packages/svelte/tests/runtime-browser/test-ssr.ts'
|
|
|
|
],
|
|
|
|
exclude: [...configDefaults.exclude, '**/samples/**'],
|
|
|
|
coverage: {
|
|
|
|
provider: 'v8',
|
2024-04-10 22:07:38 +02:00
|
|
|
reporter: ['lcov', 'html'],
|
|
|
|
include: ['packages/svelte/src/**'],
|
|
|
|
reportsDirectory: 'sites/svelte-5-preview/static/coverage',
|
|
|
|
reportOnFailure: true
|
2023-11-10 15:48:23 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|