question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug Report] Unit Testing v-form causes "TypeError: Cannot read property 'componentInstance' of null"

See original GitHub issue

Versions and Environment

Vuetify: 1.5.3 Vue: 2.6.7 Browsers: Chrome 72.0.3626.109 OS: Mac OS 10.14.2

Steps to reproduce

  1. Clone Repo
  2. Yarn install
  3. Run yarn test:unit

Expected Behavior

  1. Tests pass when run individually
  2. Tests should pass when the entire suite is run

Actual Behavior

  1. Tests pass when run individually
  2. Tests break when the entire suite is run and v-form contains v-model=“valid”. If I remove the v-model then the entire test suite passes - of course, v-model is required for validation.

Reproduction Link

https://github.com/buys-fran/vue-form-test

Other comments

It could be a leaky test issue, but I am making use of vue-test-utils’ LocalVue to better isolate tests. I believe something in the internal workings of v-form causes this problem.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:8

github_iconTop GitHub Comments

2reactions
fbuyscommented, Nov 22, 2019

I think I found a work around for our use case.

I will paste our setup here perhaps it will help someone.

import Vue from 'vue'
import Vuetify from 'vuetify'
import Vuex from 'vuex'
import Router from 'vue-router'
import axios from 'axios'
import { merge } from 'lodash'
import { mount, createLocalVue } from '@vue/test-utils'

// Can't use LocalVue Issue: https://github.com/vuetifyjs/vuetify/issues/4068#issuecomment-422406319
Vue.use(Vuetify)

const localVue = createLocalVue()
localVue.use(Vuex)
localVue.use(Router)
const router = new Router()

const $http = jest.mock('axios')

const createWrapper = function(component, { overrides, store } = {}) {
  const defaultMountingOptions = {
    mocks: {
      $http,
    },
    propsData: {},
    localVue,
    router,
    store: store || new Vuex.Store({}),
  }

  return mount(component, merge(defaultMountingOptions, overrides))
}

export default createWrapper
1reaction
willypelzcommented, May 11, 2020

@buys-fran this actually solves the problem stated above. cool

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular 5 / Jasmine Unit Test - Cannot read property ...
I found out the problem. The error message Cannot read property 'componentInstance' of undefined made me focus on the component = fixture.
Read more >
cannot read property 'value' of undefined angular unit test ...
I'm new to Angular and Typescript and cannot get to the bottom of this console error: "ERROR TypeError: Cannot read property 'value' of...
Read more >
Testing Components with children - Testing Angular
A unit test of HomeComponent does not render these children. The host elements are rendered, but they remain empty.
Read more >
Angular unit testing 101 (with examples) - DEV Community ‍ ‍
If for some reason you want to change it, you can do so in the test.ts file. Jasmine. Jasmine is a popular Javascript...
Read more >
Angular Testing Cannot Read Property 'Name' Of Undefined
Empty jQuery objects are now properly shown in error messages in the Command Log. ... Jest and Enzyme unit test: TypeError: Cannot read...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found