Last active
April 25, 2019 11:43
-
-
Save ndabAP/93d8f15df5cc546651ce3a70216a59ef to your computer and use it in GitHub Desktop.
Mock computed property of Vue.js mixin
This file contains 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 Vue from 'vue' | |
import 'babel-polyfill' | |
import Component from '~/components/Component' | |
import { | |
mount | |
} from 'vue-test-utils' | |
import sinon from 'sinon' | |
import { | |
assert | |
} from 'chai' | |
describe('ComponentMixin.js', () => { | |
it('should', () => { | |
Component.mixins['0']['computed']['property'] = () => true // Considering mixins computed property is has key property | |
const wrapper = mount(Component) | |
assert.equal(wrapper.vm.property, true) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use Vue test utils and mock using options with
computed
for mixin computed properties andmethods
for mixin methods.https://vue-test-utils.vuejs.org/api/options.html#other-options