Last active
December 12, 2018 10:49
-
-
Save balataca/f114460759874e85adfed73e3beb72cd to your computer and use it in GitHub Desktop.
Test method inside Vuejs mounted lifecycle hook with Jest
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { mount } from '@vue/test-utils' | |
import Component from '.' | |
describe('Component', () => { | |
describe('mounted', () => { | |
let wrapper | |
let spy | |
beforeEach(() => { | |
spy = jest.spyOn(Component.methods, 'methodToMock') | |
wrapper = mount(Component) | |
}) | |
afterEach(() => { | |
spy.mockClear() | |
}) | |
it('should call method methodToMock', () => { | |
expect(spy).toHaveBeenCalled() | |
}) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment