From 0500d7dbf383271145e1e54d24e986abbfefa3b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Mino?= Date: Sun, 28 Jul 2024 23:42:49 +0200 Subject: [PATCH] tests --- .../generator/client/react/tsconfig.json | 26 +++++++++---------- .../client/react/vitest.config.ts.mustache | 14 +++------- .../generator/client/vue/tsconfig.json | 9 +------ .../client/vue/vitest.config.ts.mustache | 14 ++++------ 4 files changed, 22 insertions(+), 41 deletions(-) diff --git a/src/main/resources/generator/client/react/tsconfig.json b/src/main/resources/generator/client/react/tsconfig.json index e2084baf902..b8a04c06c42 100644 --- a/src/main/resources/generator/client/react/tsconfig.json +++ b/src/main/resources/generator/client/react/tsconfig.json @@ -1,28 +1,26 @@ { "compilerOptions": { - "target": "ESNext", + "target": "esnext", "useDefineForClassFields": true, - "lib": ["DOM", "DOM.Iterable", "ESNext"], - "allowJs": false, + "module": "esnext", + "moduleResolution": "node", + "strict": true, + "jsx": "react-jsx", "skipLibCheck": true, + "resolveJsonModule": true, "esModuleInterop": false, + "lib": ["dom", "DOM.Iterable", "esnext"], + "types": ["vitest/globals"], + "baseUrl": ".", "allowSyntheticDefaultImports": true, - "strict": true, "forceConsistentCasingInFileNames": true, - "resolveJsonModule": true, "isolatedModules": true, "noEmit": true, - "jsx": "react-jsx", "composite": false, - "module": "esnext", - "moduleResolution": "node", - "baseUrl": "src", - "types": ["vitest/globals"], "paths": { - "@/*": ["main/webapp/app/*"], - "@assets/*": ["main/webapp/assets/*"] + "@/*": ["src/main/webapp/app/*"], + "@assets/*": ["src/main/webapp/assets/*"] } }, - "include": ["vite.config.ts", "src"], - "exclude": ["src/test/javascript/integration/**/*spec.ts", "node_modules"] + "include": ["src/main/**/*", "src/test/javascript/spec/**/*.ts"] } diff --git a/src/main/resources/generator/client/react/vitest.config.ts.mustache b/src/main/resources/generator/client/react/vitest.config.ts.mustache index 69366491a58..f27912a61fd 100644 --- a/src/main/resources/generator/client/react/vitest.config.ts.mustache +++ b/src/main/resources/generator/client/react/vitest.config.ts.mustache @@ -1,15 +1,12 @@ /// -import { defineConfig } from 'vite'; +import { coverageConfigDefaults, defineConfig } from 'vitest/config' import tsconfigPaths from 'vite-tsconfig-paths'; import react from '@vitejs/plugin-react'; import path from 'path'; export default defineConfig({ plugins: [react(), tsconfigPaths()], - resolve: { - alias: [{ find: '@', replacement: path.resolve(__dirname, 'src/main/webapp/app') }], - }, test: { reporters: ['verbose', 'vitest-sonar-reporter'], outputFile: { @@ -25,18 +22,15 @@ export default defineConfig({ }, environment: 'jsdom', cache: false, - include: ['src/test/javascript/spec/**/*.(spec|test).(ts|tsx)'], - exclude: ['node_modules', 'src/test/javascript/integration/**/*.spec.ts'], + include: ['src/test/javascript/spec/**/*.{test,spec}.?(c|m)[jt]s?(x)'], coverage: { - all: true, thresholds: { perFile: true, autoUpdate: true, 100: true, }, - include: ['src/main/webapp/app/**/*.ts', 'src/main/webapp/app/**/*.tsx'], - exclude: ['src/main/webapp/app/index.tsx', 'src/main/webapp/app/**/*.d.ts'], - clean: true, + include: ['src/main/webapp/app/**/*.ts?(x)'], + exclude: ['src/main/webapp/app/index.tsx', ...coverageConfigDefaults.exclude], provider: 'istanbul', reportsDirectory: '{{projectBuildDirectory}}/test-results/', reporter: ['html', 'json-summary', 'text', 'text-summary', 'lcov', 'clover'], diff --git a/src/main/resources/generator/client/vue/tsconfig.json b/src/main/resources/generator/client/vue/tsconfig.json index 6a6b790d416..4f8ed34ec97 100644 --- a/src/main/resources/generator/client/vue/tsconfig.json +++ b/src/main/resources/generator/client/vue/tsconfig.json @@ -17,12 +17,5 @@ "@/*": ["src/main/webapp/app/*"] } }, - "include": [ - "src/main/webapp/**/*.ts", - "src/main/webapp/**/*.d.ts", - "src/main/webapp/**/*.tsx", - "src/main/webapp/**/*.vue", - "src/test/javascript/spec/**/*.ts" - ], - "exclude": ["./node_modules"] + "include": ["src/main/**/*", "src/test/javascript/spec/**/*.ts"] } diff --git a/src/main/resources/generator/client/vue/vitest.config.ts.mustache b/src/main/resources/generator/client/vue/vitest.config.ts.mustache index 53a3ab8fe5a..17e56e70938 100644 --- a/src/main/resources/generator/client/vue/vitest.config.ts.mustache +++ b/src/main/resources/generator/client/vue/vitest.config.ts.mustache @@ -1,14 +1,12 @@ /// -import { defineConfig } from 'vite'; +import { coverageConfigDefaults, defineConfig } from 'vitest/config' +import tsconfigPaths from 'vite-tsconfig-paths'; import vue from '@vitejs/plugin-vue'; import path from 'path'; export default defineConfig({ - plugins: [vue()], - resolve: { - alias: [{ find: '@', replacement: path.resolve(__dirname, 'src/main/webapp/app') }], - }, + plugins: [vue(), tsconfigPaths()], test: { reporters: ['verbose', 'vitest-sonar-reporter'], outputFile: { @@ -24,8 +22,7 @@ export default defineConfig({ }, environment: 'jsdom', cache: false, - include: ['src/test/javascript/spec/**/*.(spec|test).(ts|tsx)'], - exclude: ['node_modules', 'src/test/javascript/integration/**/*.spec.ts'], + include: ['src/test/javascript/spec/**/*.{test,spec}.?(c|m)[jt]s?(x)'], coverage: { thresholds: { perFile: true, @@ -35,10 +32,9 @@ export default defineConfig({ exclude: [ 'src/main/webapp/**/*.component.ts', 'src/main/webapp/app/main.ts', - '.eslintrc.cjs', - '.lintstagedrc.cjs', 'src/test/**/*', '{{projectBuildDirectory}}/**', + ...coverageConfigDefaults.exclude, ], provider: 'istanbul', reportsDirectory: '{{projectBuildDirectory}}/test-results/',