Open syonip opened 7 years ago
@syonip Could you provide more detail about how the vm was constructed?
Btw I'm not sure sinon.spy()
can work will with vue's reactive data system.
Thanks for helping.
Here is the vm creation function:
import Vue from 'vue'
import vuenit from 'vuenit'
const EditorInjector = require('!!vue-loader?inject!renderer/components/MainPageView/Editor.vue')
function createVm(mockedComp) {
const EditorWithMocks = EditorInjector({
'../../../api/file-access': {
saveFile: sinon.stub()
}
})
mockedComp = mockedComp || EditorWithMocks
const { $router } = vuenit.mockRouter()
const $store = vuenit.store({
getters: {
mainPassword() {
return '123'
}
}
})
const options = {
inject: {
$router,
$store
},
stubComponents: true
}
const vm = vuenit.mount(mockedComp, options)
return vm
}
I don't think it's to do with sinon.spy, because this test used to pass before I changed the implementation to use vue-rx.
There is also an issue concerning Angular, RxJS observables, and unit tests (angular/angular#10127) where some observables don't fire when the clock is mocked. In that issue there are some workarounds described and also an explanation why this happens with a mocked clock. I couldn't completely verify this because at some point I got lost in RxJS's source code but the explanation sounds reasonable.
@syonip I'm testing karma.I 'm using typescript. But the TS2339 occur when I use vueRx
I am testing with karma, and I've notice this.$watchAsObservable('text') doesn't emit values even though this.text has changed. Thanks.
The test:
The code: