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.

Adebayo Oluwadamilola (3) [Avatar] Offline
// ItemList.vue
import Item from '../components/Item.vue'

export default {
components: {
data () {
return {
displayItems: window.items

beforeMount() {

import { shallowMount } from '@vue/test-utils'
import ItemList from '../ItemList.vue'
import Item from '../../components/Item.vue'

describe('ItemList.vue', () => {
test('renders an Item with data for each item in window.items', () => {
window.items = [{}, {}, {}]
const wrapper = shallowMount(ItemList)
const items = wrapper.findAll(Item)
items.wrappers.forEach((wrapper, i) => {

test('calls $bar start on load', () => {
const $bar = {
start: jest.fn(),
finish: () => {}
shallowMount(ItemList, {mocks: { $bar }})

// main.js
import Vue from 'vue'
import App from './App.vue'
import ProgressBar from './components/ProgressBar.vue'

Vue.config.productionTip = false

const bar = new Vue(ProgressBar).$mount() // #A
Vue.prototype.$bar = bar // #B
document.body.appendChild(bar.$el) // #C

new Vue({ // #D
el: '#app',
render: h => h(App)

But i keep getting the error [Vue warn]: Error in config.errorHandler: "TypeError: Cannot read property 'start' of undefined"

Please what am i missing ?
Adebayo Oluwadamilola (3) [Avatar] Offline
I saw your response on the previously asked question, but that does not help me much
Adebayo Oluwadamilola (3) [Avatar] Offline
Edd Yerburgh (42) [Avatar] Offline
The issue is that you are not passing a mock in the first unit test. If you continue reading the book there is a section that shows you how to rewrite the test passing in $bar as an instance property using the mocks option.