Это модульный тест MOCHA CHAI: users.spec.js:
import { expect } from "chai";
import { shallowMount } from "@vue/test-utils";
import Users from "@/components/Users.vue";
const wrapper = shallowMount(Users);
describe("Users test", () => {
it("Displays nice hello message", () => {
expect(wrapper.vm.$data.msg).to.equal("Welcome to Crypto Info");
});
it("users model is an array", () => {
expect(wrapper.vm.$data.users).to.be.an("array");
});
it("getUsers() to be a function", () => {
expect(wrapper.vm.$methods.getUsers()).to.be.a("function");
});
});
Я не могу найти правильный синтаксис для своего третьего теста. Я перепробовал много вещей. $ method.getUsers () не работает.
1) Users test
getUsers() to be a function:
TypeError: Cannot read property 'getUsers' of undefined
at Context.it (dist\js\webpack:\tests\unit\users.spec.js:15:1)
Не могли бы вы мне помочь? Спасибо.