dev: Improve support for front end unit tests (#7163)

This commit is contained in:
miah
2026-05-31 10:41:52 -05:00
committed by GitHub
parent 7b0d1fde64
commit 364af97060
11 changed files with 719 additions and 8 deletions

View File

@@ -0,0 +1,18 @@
import { config } from "@vue/test-utils";
import { createI18n } from "vue-i18n";
function loadEnLocales() {
// eslint-disable-next-line @typescript-eslint/no-require-imports
return require("../lang/messages/en-US.json") as Record<string, string>;
}
const i18n = createI18n({
locale: "en-US",
messages: {
"en-US": loadEnLocales(),
},
});
config.global.plugins = [...(config.global.plugins ?? []), i18n];
export { i18n };

View File

@@ -1,3 +1,4 @@
import { mount } from "@vue/test-utils";
import { createI18n } from "vue-i18n";
function loadEnLocales() {
@@ -14,3 +15,12 @@ export function stubI18n() {
});
return i18n.global;
}
export const makeWrapper = <T>(setup: () => T) => {
const Wrapper = {
template: "<div />",
setup,
};
const { vm } = mount(Wrapper);
return vm as unknown as ReturnType<typeof Wrapper.setup>;
};