Skip to content

Commit

Permalink
Merge pull request #10879 from murdos/snaphot-assertions
Browse files Browse the repository at this point in the history
Generator: add the ability to snapshot test generated files in module tests
  • Loading branch information
murdos authored Sep 18, 2024
2 parents 000988c + 97a6a0a commit a8924d9
Show file tree
Hide file tree
Showing 14 changed files with 919 additions and 406 deletions.
7 changes: 7 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
<frontend-maven-plugin.version>1.15.0</frontend-maven-plugin.version>
<checksum-maven-plugin.version>1.11</checksum-maven-plugin.version>
<maven-antrun-plugin.version>3.1.0</maven-antrun-plugin.version>
<approvaltests.version>24.4.0</approvaltests.version>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -256,6 +257,12 @@
<artifactId>mongodb</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.approvaltests</groupId>
<artifactId>approvaltests</artifactId>
<version>${approvaltests.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
16 changes: 16 additions & 0 deletions src/test/java/tech/jhipster/lite/PackageSettings.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package tech.jhipster.lite;

import org.approvaltests.core.ApprovalFailureReporter;
import org.approvaltests.reporters.*;

/**
* ApprovalTests.Java configuration.
* */
public class PackageSettings {

private static final String ApprovalBaseDirectory = "../resources";
private static final ApprovalFailureReporter UseReporter = new FirstWorkingReporter(
new AutoApproveWhenEmptyReporter(),
new DiffReporter()
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,46 +62,13 @@ void shouldCreateVueModule() {
.and()
.hasPrefixedFiles("", "eslint.config.js", "tsconfig.build.json", "vite.config.ts", "vitest.config.ts")
.hasFile("tsconfig.json")
.containing("\"extends\": \"@vue/tsconfig/tsconfig.dom.json\"")
.containing("\"allowJs\": true,")
.containing("\"sourceMap\": true,")
.containing("\"types\": [\"vite/client\", ")
.matchingSavedSnapshot()
.and()
.hasFile("vitest.config.ts")
.containing("import vue from '@vitejs/plugin-vue';")
.containing("plugins: [vue(), tsconfigPaths()],")
.containing("environment: 'jsdom',")
.containing("""
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',
"""
)
.matchingSavedSnapshot()
.and()
.hasFile("eslint.config.js")
.containing("import vue from 'eslint-plugin-vue';")
.containing("""
...vue.configs['flat/recommended'],
{
files: ['**/*.vue'],
languageOptions: {
parserOptions: { parser: '@typescript-eslint/parser' },
globals: { ...globals.browser },
},
},
"""
)
.containing("""
rules: {
quotes: ['error', 'single', { avoidEscape: true }],
'@typescript-eslint/no-empty-object-type': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'vue/html-self-closing': 'off',
"""
)
.matchingSavedSnapshot()
.and()
.hasFiles("src/main/webapp/app/shared/http/infrastructure/secondary/AxiosHttp.ts")
.hasFiles("src/main/webapp/index.html")
Expand Down
Loading

0 comments on commit a8924d9

Please sign in to comment.