mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-11-22 09:13:18 +03:00
chore: split vitest (#3426)
This commit is contained in:
parent
8185ee991b
commit
0ab1cfdeb6
5
.github/workflows/build.yml
vendored
5
.github/workflows/build.yml
vendored
@ -350,9 +350,8 @@ jobs:
|
||||
- name: Run unit tests
|
||||
if: ${{ matrix.spec.test }}
|
||||
shell: bash
|
||||
run: yarn nx test @affine/monorepo
|
||||
env:
|
||||
NATIVE_TEST: 'true'
|
||||
run: yarn vitest
|
||||
working-directory: ./apps/electron
|
||||
|
||||
- name: Download core artifact
|
||||
uses: actions/download-artifact@v3
|
||||
|
@ -54,6 +54,7 @@
|
||||
"ts-node": "^10.9.1",
|
||||
"undici": "^5.22.1",
|
||||
"uuid": "^9.0.0",
|
||||
"vitest": "^0.33.0",
|
||||
"which": "^3.0.1",
|
||||
"zx": "^7.2.3"
|
||||
},
|
||||
|
31
apps/electron/vitest.config.ts
Normal file
31
apps/electron/vitest.config.ts
Normal file
@ -0,0 +1,31 @@
|
||||
import { resolve } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
import { defineConfig } from 'vitest/config';
|
||||
|
||||
const rootDir = fileURLToPath(new URL('../..', import.meta.url));
|
||||
const pluginOutputDir = resolve(rootDir, './apps/electron/dist/plugins');
|
||||
|
||||
export default defineConfig({
|
||||
resolve: {
|
||||
alias: {
|
||||
// prevent tests using two different sources of yjs
|
||||
yjs: resolve(rootDir, 'node_modules/yjs'),
|
||||
},
|
||||
},
|
||||
define: {
|
||||
'process.env.PLUGIN_DIR': JSON.stringify(pluginOutputDir),
|
||||
},
|
||||
test: {
|
||||
include: ['./src/**/*.spec.ts'],
|
||||
exclude: ['**/node_modules', '**/dist', '**/build', '**/out'],
|
||||
testTimeout: 5000,
|
||||
singleThread: true,
|
||||
threads: false,
|
||||
coverage: {
|
||||
provider: 'istanbul', // or 'c8'
|
||||
reporter: ['lcov'],
|
||||
reportsDirectory: resolve(rootDir, '.coverage/electron'),
|
||||
},
|
||||
},
|
||||
});
|
@ -36,9 +36,9 @@
|
||||
"lint:prettier:fix": "prettier --ignore-unknown --cache --write .",
|
||||
"lint": "yarn lint:eslint && yarn lint:prettier",
|
||||
"lint:fix": "yarn lint:eslint:fix && yarn lint:prettier:fix",
|
||||
"test": "ENABLE_PRELOADING=false vitest --run",
|
||||
"test:ui": "ENABLE_PRELOADING=false vitest --ui",
|
||||
"test:coverage": "ENABLE_PRELOADING=false vitest run --coverage",
|
||||
"test": "vitest --run",
|
||||
"test:ui": "vitest --ui",
|
||||
"test:coverage": "vitest run --coverage",
|
||||
"notify": "node scripts/notify.mjs",
|
||||
"circular": "madge --circular --ts-config ./tsconfig.json ./apps/core/src/pages/**/*.tsx",
|
||||
"typecheck": "tsc -b tsconfig.json --diagnostics",
|
||||
|
@ -1,4 +1,4 @@
|
||||
import path, { resolve } from 'node:path';
|
||||
import { resolve } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
|
||||
import { vanillaExtractPlugin } from '@vanilla-extract/vite-plugin';
|
||||
@ -13,10 +13,8 @@ export default defineConfig({
|
||||
assetsInclude: ['**/*.md'],
|
||||
resolve: {
|
||||
alias: {
|
||||
'next/router': 'next-router-mock',
|
||||
'next/config': resolve(rootDir, './scripts/vitest/next-config-mock.ts'),
|
||||
// prevent tests using two different sources of yjs
|
||||
yjs: path.resolve(__dirname, 'node_modules/yjs'),
|
||||
yjs: resolve(rootDir, 'node_modules/yjs'),
|
||||
},
|
||||
},
|
||||
define: {
|
||||
@ -30,25 +28,20 @@ export default defineConfig({
|
||||
resolve(rootDir, './scripts/setup/lottie-web.ts'),
|
||||
resolve(rootDir, './scripts/setup/global.ts'),
|
||||
],
|
||||
// split tests that include native addons or not
|
||||
include: process.env.NATIVE_TEST
|
||||
? ['apps/electron/src/**/*.spec.ts']
|
||||
: [
|
||||
'packages/**/*.spec.ts',
|
||||
'packages/**/*.spec.tsx',
|
||||
'apps/web/**/*.spec.ts',
|
||||
'apps/web/**/*.spec.tsx',
|
||||
'tests/unit/**/*.spec.ts',
|
||||
'tests/unit/**/*.spec.tsx',
|
||||
],
|
||||
include: [
|
||||
resolve(rootDir, 'packages/**/*.spec.ts'),
|
||||
resolve(rootDir, 'packages/**/*.spec.tsx'),
|
||||
resolve(rootDir, 'apps/web/**/*.spec.ts'),
|
||||
resolve(rootDir, 'apps/web/**/*.spec.tsx'),
|
||||
resolve(rootDir, 'tests/unit/**/*.spec.ts'),
|
||||
resolve(rootDir, 'tests/unit/**/*.spec.tsx'),
|
||||
],
|
||||
exclude: ['**/node_modules', '**/dist', '**/build', '**/out'],
|
||||
testTimeout: 5000,
|
||||
singleThread: Boolean(process.env.NATIVE_TEST),
|
||||
threads: !process.env.NATIVE_TEST,
|
||||
coverage: {
|
||||
provider: 'istanbul', // or 'c8'
|
||||
reporter: ['lcov'],
|
||||
reportsDirectory: '.coverage/store',
|
||||
reportsDirectory: resolve(rootDir, '.coverage/store'),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user