The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

422343 (1) [Avatar] Offline
#1
I am getting this error in the loadItems method on ItemsList.vue application

loadItems () {
this.$bar.start ()
fetchListData ('top')
.then (items => {
this.displayItems = items
this.$bar.finish ()
})
}

if bar is being loaded in the main.js file and mounted to the Vue Instance then do I need to import it into the ItemList.vue file?



main.js ----------


import ProgressBar from './components/ProgressBar'

Vue.config.productionTip = false

const bar = new Vue (ProgressBar).$mount ()
Vue.prototype.$bar = bar
document.body.appendChild (bar.$el)

new Vue ({
el: '#app',
render: h => h (App)
})
Edd Yerburgh (42) [Avatar] Offline
#2
Sorry you're having this problem.

In chapter 4 there is a section on testing Vue instance properties using the Vue Test Utils mocks option—https://vue-test-utils.vuejs.org/api/options.html#mocks

You can see an example of testing the ItemList component with the mocks option here—https://github.com/eddyerburgh/vue-hackernews/blob/chapter-7/src/views/__tests__/ItemList.spec.js#L18