From 2a9f6663c1439bfc80dbc48fd6b581a480b49faa Mon Sep 17 00:00:00 2001 From: Angel Mendez Cano Date: Fri, 2 Feb 2024 18:54:50 -0600 Subject: [PATCH] feat: add vitest configuration file - add vitest configuration - update tsconfig.json so that test files does not throw error with global definitions such as expect, test --- tsconfig.json | 3 ++- vitest.config.js | 31 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 vitest.config.js diff --git a/tsconfig.json b/tsconfig.json index 61b2cfaf..7061561e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -12,9 +12,10 @@ "experimentalDecorators": true, "esModuleInterop": true, "noUnusedLocals": true, - "moduleResolution": "node", + "moduleResolution": "Bundler", "declaration": true, "resolveJsonModule": true, + "types": ["vitest/globals"], // TODO: Enable the following options later. // "forceConsistentCasingInFileNames": true, diff --git a/vitest.config.js b/vitest.config.js new file mode 100644 index 00000000..45ac399a --- /dev/null +++ b/vitest.config.js @@ -0,0 +1,31 @@ +import { defineConfig, mergeConfig } from 'vitest/config' +import viteConfig from './vite.config' + +export default defineConfig(configEnv => mergeConfig( + viteConfig(configEnv), + defineConfig({ + test: { + globals: true, + environment: 'jsdom', + alias: { + "\\.css$": "identity-obj-proxy", + "\\.svg\\?react$": "/test/mocks/svgr.ts", + "^\\./IndexedDBWorker\\?worker$": "/test/mocks/workerMock.ts", + "^\\./olm$": "/test/mocks/olmMock.ts" + }, + css: { + modules: { + classNameStrategy: 'non-scoped' + } + }, + include: [ + "test/**/*-test.[jt]s?(x)" + ], + coverage: { + reporter: ['text', 'html'], + exclude: [ + 'node_modules/' + ] + } + } +}))) \ No newline at end of file