我正在尝试对通过windowTopScroll()
方法调用mounted
的文件进行测试。
玩笑正在抛出ReferenceError: windowTopScroll is not defined
这是我的测试代码。
import Vue from 'vue';
import sinon from 'sinon'
import WorkTimeline from '../../components/WorkTimeline.vue';
import { createLocalVue, mount, shallowMount } from '@vue/test-utils';
Vue.config.ignoredElements = ['name']
describe("WorkTimeline.test.js", () => {
const windowTopScroll = jest.fn()
test('renders WorkTimeline Slider', () => {
const wrapper = shallowMount(WorkTimeline, {
mocks: {
$t: () => {},
windowTopScroll: jest.fn()
},
});
expect(windowTopScroll).toHaveBeenCalled();
});