Files
AFFiNE-Mirror/vitest.config.ts
DarkSky f34e25e122 test: migrate test & utils (#14569)
#### PR Dependency Tree


* **PR #14569** 👈

This tree was auto-generated by
[Charcoal](https://github.com/danerwilliams/charcoal)

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Chores**
* Upgraded development test tooling to Vitest v4 and added Playwright
browser test integration; normalized test configurations and CI shard
matrix.

* **Tests**
* Added a large suite of new integration tests covering editor flows
(edgeless, database, embeds, images, latex, code, clipboard,
multi-editor, presentation, undo/redo, etc.).
* Removed numerous end-to-end Playwright test suites across the same
feature areas.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-03-07 04:12:27 +08:00

80 lines
2.1 KiB
TypeScript

import { resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
import { vanillaExtractPlugin } from '@vanilla-extract/vite-plugin';
import * as fg from 'fast-glob';
import swc from 'unplugin-swc';
import { defineConfig } from 'vitest/config';
const rootDir = fileURLToPath(new URL('.', import.meta.url));
export default defineConfig({
plugins: [
vanillaExtractPlugin(),
// https://github.com/vitejs/vite-plugin-react-swc/issues/85#issuecomment-2003922124
swc.vite({
jsc: {
preserveAllComments: true,
parser: {
syntax: 'typescript',
dynamicImport: true,
tsx: true,
decorators: true,
},
target: 'es2022',
externalHelpers: false,
transform: {
react: {
runtime: 'automatic',
},
useDefineForClassFields: false,
decoratorVersion: '2022-03',
},
},
sourceMaps: true,
inlineSourcesContent: true,
}),
],
assetsInclude: ['**/*.md', '**/*.zip'],
resolve: {
alias: {
// prevent tests using two different sources of yjs
yjs: resolve(rootDir, 'node_modules/yjs'),
'@affine/core': fileURLToPath(
new URL('./packages/frontend/core/src', import.meta.url)
),
},
},
test: {
projects: [
'.',
'./packages/frontend/apps/electron',
'./blocksuite/**/*/vitest.config.ts',
],
setupFiles: [
resolve(rootDir, './scripts/setup/polyfill.ts'),
resolve(rootDir, './scripts/setup/lit.ts'),
resolve(rootDir, './scripts/setup/vi-mock.ts'),
resolve(rootDir, './scripts/setup/global.ts'),
],
include: [
// rootDir cannot be used as a pattern on windows
fg.convertPathToPattern(rootDir) +
'packages/{common,frontend}/**/*.spec.{ts,tsx}',
],
exclude: [
'**/node_modules',
'**/dist',
'**/build',
'**/out,',
'**/packages/frontend/apps/electron',
],
testTimeout: 5000,
coverage: {
provider: 'istanbul', // or 'istanbul'
reporter: ['lcov'],
reportsDirectory: resolve(rootDir, '.coverage/store'),
},
},
});