There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.
TypeScript appcrdteditorelectronknowledge-basemarkdownmironotesnotionnotion-alternativerustrust-langrust-languagetabletableviewwhiteboardwikiworkspace
chore: split vitest (#3426)
Alex Yang0ab1cfdeb659
diff --git a/.github/workflows/build.yml b/.github/workflows/build.ymlindex 57f04da0ab..424abc0ba4 100644--- a/.github/workflows/build.yml+++ b/.github/workflows/build.yml@@ -350,9 +350,8 @@ jobs:- name: Run unit testsif: ${{ 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 artifactuses: actions/download-artifact@v3diff --git a/apps/electron/package.json b/apps/electron/package.jsonindex adf75354e8..762dfbb326 100644--- a/apps/electron/package.json+++ b/apps/electron/package.json@@ -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"},diff --git a/apps/electron/vitest.config.ts b/apps/electron/vitest.config.tsnew file mode 100644index 0000000000..8bfa457c2a--- /dev/null+++ b/apps/electron/vitest.config.ts@@ -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'),+ },+ },+});diff --git a/package.json b/package.jsonindex 1c0300f738..bb5c4363b4 100644--- a/package.json+++ b/package.json@@ -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",diff --git a/vitest.config.ts b/vitest.config.tsindex 0df34bf95a..1139bac864 100644--- a/vitest.config.ts+++ b/vitest.config.ts@@ -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'),},},});diff --git a/yarn.lock b/yarn.lockindex c1dcde67b2..28d3b06c6b 100644--- a/yarn.lock+++ b/yarn.lock@@ -330,6 +330,7 @@ __metadata:ts-node: ^10.9.1undici: ^5.22.1uuid: ^9.0.0+ vitest: ^0.33.0which: ^3.0.1yjs: ^13.6.7zx: ^7.2.3