diff --git a/src/main/java/tech/jhipster/lite/generator/client/react/core/domain/ReactCoreModulesFactory.java b/src/main/java/tech/jhipster/lite/generator/client/react/core/domain/ReactCoreModulesFactory.java index 86467a94cb2..cba6bb557af 100644 --- a/src/main/java/tech/jhipster/lite/generator/client/react/core/domain/ReactCoreModulesFactory.java +++ b/src/main/java/tech/jhipster/lite/generator/client/react/core/domain/ReactCoreModulesFactory.java @@ -186,14 +186,16 @@ private Consumer patchVitestConfig(JHipsterModuleProperti .add(lineAfterRegex("from 'vitest/config';"), "import react from '@vitejs/plugin-react';") .add(text("plugins: ["), "plugins: [react(), ") .add(text("environment: 'node',"), "environment: 'jsdom',") - .add(vitestCoverageExclusion(properties,"src/main/webapp/app/index.tsx")) - .add(vitestCoverageExclusion(properties,"src/main/webapp/app/injections.ts")) + .add(vitestCoverageExclusion("src/main/webapp/app/index.tsx")) + .add(vitestCoverageExclusion("src/main/webapp/app/injections.ts")) .and(); //@formatter:on } - private static MandatoryReplacer vitestCoverageExclusion(JHipsterModuleProperties properties, String filePattern) { - Indentation indentation = properties.indentation(); - return new MandatoryReplacer(lineAfterRegex("configDefaults.coverage.exclude"), indentation.times(4) + "'" + filePattern + "',"); + private static MandatoryReplacer vitestCoverageExclusion(String filePattern) { + return new MandatoryReplacer( + text("(configDefaults.coverage.exclude as string[])"), + "(configDefaults.coverage.exclude as string[])" + ", '" + filePattern + "'" + ); } } diff --git a/src/main/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactory.java b/src/main/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactory.java index 6119d26c382..68f575c4f2a 100644 --- a/src/main/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactory.java +++ b/src/main/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactory.java @@ -185,17 +185,19 @@ private Consumer patchVitestConfig(JHipsterModuleProperti .add(lineAfterRegex("from 'vitest/config';"), "import vue from '@vitejs/plugin-vue';") .add(text("plugins: ["), "plugins: [vue(), ") .add(text("environment: 'node',"), "environment: 'jsdom',") - .add(vitestCoverageExclusion(properties,"src/main/webapp/**/*.component.ts")) - .add(vitestCoverageExclusion(properties,"src/main/webapp/app/router.ts")) - .add(vitestCoverageExclusion(properties,"src/main/webapp/app/injections.ts")) - .add(vitestCoverageExclusion(properties,"src/main/webapp/app/main.ts")) + .add(vitestCoverageExclusion("src/main/webapp/**/*.component.ts")) + .add(vitestCoverageExclusion("src/main/webapp/app/router.ts")) + .add(vitestCoverageExclusion("src/main/webapp/app/injections.ts")) + .add(vitestCoverageExclusion("src/main/webapp/app/main.ts")) .and(); //@formatter:on } - private static MandatoryReplacer vitestCoverageExclusion(JHipsterModuleProperties properties, String filePattern) { - Indentation indentation = properties.indentation(); - return new MandatoryReplacer(lineAfterRegex("configDefaults.coverage.exclude"), indentation.times(4) + "'" + filePattern + "',"); + private static MandatoryReplacer vitestCoverageExclusion(String filePattern) { + return new MandatoryReplacer( + text("(configDefaults.coverage.exclude as string[])"), + "(configDefaults.coverage.exclude as string[])" + ", '" + filePattern + "'" + ); } public JHipsterModule buildPiniaModule(JHipsterModuleProperties properties) { diff --git a/src/main/resources/generator/typescript/vitest.config.ts.mustache b/src/main/resources/generator/typescript/vitest.config.ts.mustache index 30452b097ad..eef80168bae 100644 --- a/src/main/resources/generator/typescript/vitest.config.ts.mustache +++ b/src/main/resources/generator/typescript/vitest.config.ts.mustache @@ -28,9 +28,7 @@ export default defineConfig({ 100: true, }, include: ['src/main/webapp/**/*.ts?(x)'], - exclude: [ - ...configDefaults.coverage.exclude as string[], - ], + exclude: [...(configDefaults.coverage.exclude as string[])], provider: 'istanbul', reportsDirectory: '{{projectBuildDirectory}}/test-results/', reporter: ['html', 'json-summary', 'text', 'text-summary', 'lcov', 'clover'], diff --git a/src/test/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactoryTest.java b/src/test/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactoryTest.java index e246e6ae9cf..48c462f8803 100644 --- a/src/test/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactoryTest.java +++ b/src/test/java/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactoryTest.java @@ -79,7 +79,7 @@ void shouldCreateVueModule() { """ ) .and() - .hasPrefixedFiles("", "eslint.config.js", "tsconfig.build.json", "vite.config.ts", "vitest.config.ts") + .hasPrefixedFiles("", "eslint.config.js", "tsconfig.build.json", "vite.config.ts") .hasFile("tsconfig.json") .matchingSavedSnapshot() .and() diff --git a/src/test/resources/tech/jhipster/lite/generator/client/react/core/domain/ReactCoreModulesFactoryTest.shouldBuildModuleWithStyle.vitest.config.ts.approved.txt b/src/test/resources/tech/jhipster/lite/generator/client/react/core/domain/ReactCoreModulesFactoryTest.shouldBuildModuleWithStyle.vitest.config.ts.approved.txt index c155fa13132..87ad4ca73b1 100644 --- a/src/test/resources/tech/jhipster/lite/generator/client/react/core/domain/ReactCoreModulesFactoryTest.shouldBuildModuleWithStyle.vitest.config.ts.approved.txt +++ b/src/test/resources/tech/jhipster/lite/generator/client/react/core/domain/ReactCoreModulesFactoryTest.shouldBuildModuleWithStyle.vitest.config.ts.approved.txt @@ -29,11 +29,7 @@ export default defineConfig({ 100: true, }, include: ['src/main/webapp/**/*.ts?(x)'], - exclude: [ - ...configDefaults.coverage.exclude as string[], - 'src/main/webapp/app/injections.ts', - 'src/main/webapp/app/index.tsx', - ], + exclude: [...(configDefaults.coverage.exclude as string[]), 'src/main/webapp/app/injections.ts', 'src/main/webapp/app/index.tsx'], provider: 'istanbul', reportsDirectory: 'target/test-results/', reporter: ['html', 'json-summary', 'text', 'text-summary', 'lcov', 'clover'], diff --git a/src/test/resources/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactoryTest.shouldCreateVueModule.vitest.config.ts.approved.txt b/src/test/resources/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactoryTest.shouldCreateVueModule.vitest.config.ts.approved.txt index 6307b1faa2d..bb802095c8d 100644 --- a/src/test/resources/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactoryTest.shouldCreateVueModule.vitest.config.ts.approved.txt +++ b/src/test/resources/tech/jhipster/lite/generator/client/vue/core/domain/VueModulesFactoryTest.shouldCreateVueModule.vitest.config.ts.approved.txt @@ -29,13 +29,7 @@ export default defineConfig({ 100: true, }, include: ['src/main/webapp/**/*.ts?(x)'], - exclude: [ - ...configDefaults.coverage.exclude as string[], - 'src/main/webapp/app/main.ts', - 'src/main/webapp/app/injections.ts', - 'src/main/webapp/app/router.ts', - 'src/main/webapp/**/*.component.ts', - ], + exclude: [...(configDefaults.coverage.exclude as string[]), 'src/main/webapp/app/main.ts', 'src/main/webapp/app/injections.ts', 'src/main/webapp/app/router.ts', 'src/main/webapp/**/*.component.ts'], provider: 'istanbul', reportsDirectory: 'target/test-results/', reporter: ['html', 'json-summary', 'text', 'text-summary', 'lcov', 'clover'],