Last active
April 22, 2020 17:09
-
-
Save achhunna/e4750cb72dc054f2c0110a05f07463e4 to your computer and use it in GitHub Desktop.
Factory function to mount component
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
let wrapper; | |
const factory = (computed = {}) => { | |
return shallowMount(Component, { | |
propsData: {}, | |
mocks: {}, | |
stubs: {}, | |
methods: {}, | |
computed, | |
}); | |
}; | |
beforeEach(() => { | |
wrapper = factory(); | |
}); | |
... | |
test('changing computed property should be updated', () => { | |
wrapper = factory({ myProperty: () => 'test' }); | |
expect(wrapper.vm.myProperty).toBe('test'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment