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