I am trying to run a test on a file where windowTopScroll()
is called on mounted
method.
Jest is throwing ReferenceError: windowTopScroll is not defined
Here is my code for the test.
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();
});