Added more tests.
This commit is contained in:
parent
5a80d42af8
commit
90b4938bdb
4 changed files with 68 additions and 6 deletions
49
tests/App.spec.ts
Normal file
49
tests/App.spec.ts
Normal file
|
|
@ -0,0 +1,49 @@
|
||||||
|
import { describe, expect, it } from "vitest";
|
||||||
|
import { mount, type VueWrapper } from "@vue/test-utils";
|
||||||
|
import { vuetify } from "./setup.vuetify";
|
||||||
|
|
||||||
|
import App from "~/App.vue";
|
||||||
|
|
||||||
|
describe("App.vue", () => {
|
||||||
|
const wrapper: VueWrapper = mount(App, {
|
||||||
|
global: {
|
||||||
|
plugins: [vuetify],
|
||||||
|
stubs: {
|
||||||
|
HeaderNavBar: true,
|
||||||
|
FooterComponent: true,
|
||||||
|
RouterView: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("Component Structure", () => {
|
||||||
|
it("renders the component", () => {
|
||||||
|
expect(wrapper.exists()).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("renders v-app as the root element", () => {
|
||||||
|
expect(wrapper.find(".v-application").exists()).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("renders HeaderNavBar component", () => {
|
||||||
|
expect(wrapper.findComponent({ name: "HeaderNavBar" }).exists()).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("renders FooterComponent component", () => {
|
||||||
|
expect(wrapper.findComponent({ name: "FooterComponent" }).exists()).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("renders v-main element", () => {
|
||||||
|
expect(wrapper.find(".v-main").exists()).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("renders v-container inside v-main", () => {
|
||||||
|
const main = wrapper.find(".v-main");
|
||||||
|
expect(main.find(".v-container").exists()).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("renders RouterView component", () => {
|
||||||
|
expect(wrapper.findComponent({ name: "RouterView" }).exists()).toBe(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
10
tests/setup.vuetify.ts
Normal file
10
tests/setup.vuetify.ts
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
import { createVuetify } from "vuetify";
|
||||||
|
import * as components from "vuetify/components";
|
||||||
|
import * as directives from "vuetify/directives";
|
||||||
|
|
||||||
|
const vuetify = createVuetify({
|
||||||
|
components,
|
||||||
|
directives,
|
||||||
|
});
|
||||||
|
|
||||||
|
export { vuetify };
|
||||||
|
|
@ -1,10 +1,14 @@
|
||||||
{
|
{
|
||||||
"extends": "./tsconfig.app.json",
|
"extends": "./tsconfig.app.json",
|
||||||
"include": ["tests/**/*.spec.ts", "env.d.ts", "src/**/*", "src/**/*.vue"],
|
"include": ["tests/**/*.ts", "env.d.ts", "src/**/*", "src/**/*.vue"],
|
||||||
"exclude": [],
|
"exclude": [],
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.vitest.tsbuildinfo",
|
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.vitest.tsbuildinfo",
|
||||||
|
|
||||||
"types": ["node", "happy-dom"]
|
"types": ["node", "happy-dom"]
|
||||||
|
},
|
||||||
|
"paths": {
|
||||||
|
"~/*": ["./src/*"],
|
||||||
|
"@/*": ["./src/*"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,12 +9,11 @@ export default mergeConfig(
|
||||||
environment: "happy-dom",
|
environment: "happy-dom",
|
||||||
exclude: [...configDefaults.exclude, "e2e/**"],
|
exclude: [...configDefaults.exclude, "e2e/**"],
|
||||||
root: fileURLToPath(new URL("./", import.meta.url)),
|
root: fileURLToPath(new URL("./", import.meta.url)),
|
||||||
reporters: [
|
setupFiles: ["./tests/setup.vuetify.ts"],
|
||||||
'default',
|
reporters: ["default", ["vitest-sonar-reporter", { outputFile: "coverage/sonar-report.xml" }]],
|
||||||
['vitest-sonar-reporter', { outputFile: 'coverage/sonar-report.xml' }],
|
|
||||||
],
|
|
||||||
coverage: {
|
coverage: {
|
||||||
reporter: ["text", "lcov"],
|
reporter: ["text", "lcov"],
|
||||||
|
exclude: [...(configDefaults.coverage.exclude || []), "**/*.css", "**/*.scss"],
|
||||||
},
|
},
|
||||||
server: {
|
server: {
|
||||||
deps: {
|
deps: {
|
||||||
|
|
@ -22,5 +21,5 @@ export default mergeConfig(
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}),
|
})
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue