Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow applying other front module after vitest config being formatted with prettier #11189

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -186,14 +186,16 @@ private Consumer<JHipsterModuleBuilder> 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 + "'"
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -185,17 +185,19 @@ private Consumer<JHipsterModuleBuilder> 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
Expand Down
Loading