Skip to content

Instantly share code, notes, and snippets.

@ndabAP
Last active April 25, 2019 11:43
Show Gist options
  • Save ndabAP/93d8f15df5cc546651ce3a70216a59ef to your computer and use it in GitHub Desktop.
Save ndabAP/93d8f15df5cc546651ce3a70216a59ef to your computer and use it in GitHub Desktop.
Mock computed property of Vue.js mixin
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)
})
})
@lukeromanowicz
Copy link

Use Vue test utils and mock using options with computed for mixin computed properties and methods for mixin methods.

https://vue-test-utils.vuejs.org/api/options.html#other-options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment