Skip to content

Instantly share code, notes, and snippets.

@achhunna
Last active April 22, 2020 17:09
Show Gist options
  • Save achhunna/e4750cb72dc054f2c0110a05f07463e4 to your computer and use it in GitHub Desktop.
Save achhunna/e4750cb72dc054f2c0110a05f07463e4 to your computer and use it in GitHub Desktop.
Factory function to mount component
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