From de2e37ec8e2074210f313efd66bec6553140ebd4 Mon Sep 17 00:00:00 2001 From: Alexander Brown Date: Sat, 17 Jan 2026 13:02:55 -0800 Subject: [PATCH] chore: merge vitest config into vite.config.mts (#8132) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Moves vitest configuration from `vitest.config.ts` into the `test` section of `vite.config.mts` and deletes the separate vitest config file. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-8132-chore-merge-vitest-config-into-vite-config-mts-2eb6d73d365081ab81b5dca11fadf13a) by [Unito](https://www.unito.io) --- lint-staged.config.mjs | 2 + .../graph/useGraphNodeManager.test.ts | 0 .../stores/templateRankingStore.test.ts | 0 vite.config.mts | 28 +++++++++-- vitest.config.ts | 48 ------------------- 5 files changed, 27 insertions(+), 51 deletions(-) rename {tests-ui/tests => src}/composables/graph/useGraphNodeManager.test.ts (100%) rename {tests-ui => src}/stores/templateRankingStore.test.ts (100%) delete mode 100644 vitest.config.ts diff --git a/lint-staged.config.mjs b/lint-staged.config.mjs index 97d22c529..d158a355d 100644 --- a/lint-staged.config.mjs +++ b/lint-staged.config.mjs @@ -1,6 +1,8 @@ import path from 'node:path' export default { + 'tests-ui/**': () => 'echo "Files in tests-ui/ are deprecated. Colocate tests with source files." && exit 1', + './**/*.js': (stagedFiles) => formatAndEslint(stagedFiles), './**/*.{ts,tsx,vue,mts}': (stagedFiles) => [ diff --git a/tests-ui/tests/composables/graph/useGraphNodeManager.test.ts b/src/composables/graph/useGraphNodeManager.test.ts similarity index 100% rename from tests-ui/tests/composables/graph/useGraphNodeManager.test.ts rename to src/composables/graph/useGraphNodeManager.test.ts diff --git a/tests-ui/stores/templateRankingStore.test.ts b/src/stores/templateRankingStore.test.ts similarity index 100% rename from tests-ui/stores/templateRankingStore.test.ts rename to src/stores/templateRankingStore.test.ts diff --git a/vite.config.mts b/vite.config.mts index 713de6866..abfce8f35 100644 --- a/vite.config.mts +++ b/vite.config.mts @@ -11,8 +11,8 @@ import IconsResolver from 'unplugin-icons/resolver' import Icons from 'unplugin-icons/vite' import Components from 'unplugin-vue-components/vite' import typegpuPlugin from 'unplugin-typegpu/vite' -import { defineConfig } from 'vite' -import type { ProxyOptions, UserConfig } from 'vite' +import { defineConfig } from 'vitest/config' +import type { ProxyOptions } from 'vite' import { createHtmlPlugin } from 'vite-plugin-html' import vueDevTools from 'vite-plugin-vue-devtools' @@ -511,5 +511,27 @@ export default defineConfig({ optimizeDeps: { exclude: ['@comfyorg/comfyui-electron-types'], entries: ['index.html'] + }, + + test: { + globals: true, + environment: 'happy-dom', + setupFiles: ['./vitest.setup.ts'], + retry: process.env.CI ? 2 : 0, + include: [ + 'src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}', + 'packages/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}' + ], + coverage: { + reporter: ['text', 'json', 'html'] + }, + exclude: [ + '**/node_modules/**', + '**/dist/**', + '**/cypress/**', + '**/.{idea,git,cache,output,temp}/**', + '**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*' + ], + silent: 'passed-only' } -}) satisfies UserConfig as UserConfig +}) diff --git a/vitest.config.ts b/vitest.config.ts deleted file mode 100644 index b74f7496c..000000000 --- a/vitest.config.ts +++ /dev/null @@ -1,48 +0,0 @@ -import vue from '@vitejs/plugin-vue' -import { FileSystemIconLoader } from 'unplugin-icons/loaders' -import Icons from 'unplugin-icons/vite' -import { defineConfig } from 'vitest/config' - -export default defineConfig({ - plugins: [ - vue(), - Icons({ - compiler: 'vue3', - customCollections: { - comfy: FileSystemIconLoader('packages/design-system/src/icons') - } - }) - ], - test: { - globals: true, - environment: 'happy-dom', - setupFiles: ['./vitest.setup.ts'], - retry: process.env.CI ? 2 : 0, - include: [ - 'src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}', - 'packages/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}' - ], - coverage: { - reporter: ['text', 'json', 'html'] - }, - exclude: [ - '**/node_modules/**', - '**/dist/**', - '**/cypress/**', - '**/.{idea,git,cache,output,temp}/**', - '**/{karma,rollup,webpack,vite,vitest,jest,ava,babel,nyc,cypress,tsup,build,eslint,prettier}.config.*' - ], - silent: 'passed-only' - }, - resolve: { - alias: { - '@/utils/formatUtil': '/packages/shared-frontend-utils/src/formatUtil.ts', - '@/utils/networkUtil': - '/packages/shared-frontend-utils/src/networkUtil.ts', - '@': '/src' - } - }, - define: { - __USE_PROD_CONFIG__: process.env.USE_PROD_CONFIG === 'true' - } -})