problem description
using Vue Test Utils, to generate wrapper, to call wrapper.vm.getCtModal (), because the ts language is used, the compiler will report that the type declaration of xxxmethod cannot be found, asking how should xxxmethod have a type declaration, or call the method of a vue instance in some other way?
the environmental background of the problems and what methods you have tried
projects created with vue cli 3 write unit tests using the officially recommended @ vue/test-utils reference book, unit tests using typescript language, mocha test framework and chai assertion library
related codes
/ / Please paste the code text below (do not replace the code with pictures)
import { expect } from "chai";
import { shallowMount } from "@vue/test-utils";
import Toast from "@/components/toast/Toast.vue";
describe("Toast.vue", () => {
it("tips", (done) => {
const tips = "";
const wrapper = shallowMount(Toast);
wrapper.vm.getCtModal("notLoginError");
wrapper.vm.$nextTick(() => {
const div = wrapper.find(".loading-title");
expect(div.text()).to.equal("");
done();
});
});
});