Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug Report] Tests failing with error TypeError: Cannot read property 'isHydrating' of undefined #13235

Closed
gadelkareem opened this issue Mar 9, 2021 · 4 comments
Labels
testing upstream Problem with a third party library that we may have to work around

Comments

@gadelkareem
Copy link

Environment

Vuetify Version: 2.4.5
Last working version: 2.2.11
Vue Version: 2.6.12
Browsers: Other
OS: Linux

Steps to reproduce

The feature/upgrade-vuetify has Vuetify 2.4.5 and that's where the tests fail

Example of test
https://gitlab.com/gadelkareem/skeleton/-/blob/feature/upgrade-vuetify/src/frontend/src/pages/dashboard/account/__tests__/update-profile.spec.js

import {createLocalVue, mount} from '@vue/test-utils'
import Vuex from 'vuex'
import VueRouter from 'vue-router'
import initData from '@@/globals/init-data'
import Page from '../update-profile'
import Vuetify from 'vuetify'

const localVue = createLocalVue()

describe('update-profile.vue', () => {
  let store, vuetify

  beforeEach(() => {
    const actions = {
      'page/title': jest.fn(),
      'loading/start': jest.fn(),
      'loading/finish': jest.fn()
    }
    const getters = {
      'user/user': () => initData().user
    }
    store = new Vuex.Store({
      actions,
      getters,
      state: {
        loading: {status: false}
      }
    })
    vuetify = new Vuetify()
  })

  it('should match snapshot', () => {
    const router = new VueRouter({})
    const w = mount(Page, {
      store,
      router,
      localVue,
      vuetify,
      stubs: ['router-link', 'router-view'],
      created() {
        this.$vuetify.lang = {
          t: () => {
          }
        }
        this.$vuetify.theme = {dark: false}
      }
    })

    expect(w.html()).toMatchSnapshot()
    w.destroy()
  })
})

Jest setup
https://gitlab.com/gadelkareem/skeleton/-/blob/feature/upgrade-vuetify/src/frontend/test/_setup.js

import Vue from 'vue'
import Vuetify from 'vuetify'
import Vuex from 'vuex'
import VueRouter from 'vue-router'

Vue.use(Vuetify)
Vue.use(Vuex)
Vue.use(VueRouter)

require('../src/plugins/mixin')
Vue.use(require('vue-chartist'))
Vue.config.silent = true

jest config https://gitlab.com/gadelkareem/skeleton/-/blob/feature/upgrade-vuetify/src/frontend/jest.config.js#L36

module.exports = {
  moduleFileExtensions: [
    'js',
    'jsx',
    'json',
    'vue'
  ],
  watchman: false,
  moduleNameMapper: {
    '^~/(.*)$': '<rootDir>/$1',
    '^~~/(.*)$': '<rootDir>/src/$1',
    '^@/(.*)$': '<rootDir>/$1',
    '^@@/(.*)$': '<rootDir>/src/$1'
  },
  transform: {
    // process js with `babel-jest`
    '^.+\\.[jt]sx?$': '<rootDir>/node_modules/babel-jest',
    // process `*.vue` files with `vue-jest`
    '.*\\.(vue)$': '<rootDir>/node_modules/vue-jest',
    '.+\\.(css|styl|less|sass|scss|svg|png|jpg|ttf|woff|woff2)$': '<rootDir>/node_modules/jest-transform-stub'
  },
  snapshotSerializers: ['<rootDir>/node_modules/jest-serializer-vue'],
  collectCoverage: false,
  collectCoverageFrom: [
    '<rootDir>/src/components/**/*.vue',
    '<rootDir>/src/pages/*.vue'
  ],
  'verbose': true,
  'modulePaths': [
    '<rootDir>/src',
    '<rootDir>/node_modules'
  ],
  'globals': {
    'NODE_ENV': 'test'
  },
  setupFiles: ['<rootDir>/test/_setup.js'],
  transformIgnorePatterns: [
    '<rootDir>/node_modules/(?!vuetify)'
  ]
}

Expected Behavior

Tests are passing on the master branch for the same project which is using version 2.2.11 https://gitlab.com/gadelkareem/skeleton/-/jobs/1020457978

Actual Behavior

Tests fail https://gitlab.com/gadelkareem/skeleton/-/jobs/1082962881

Reproduction Link

https://gitlab.com/gadelkareem/skeleton/-/jobs/1082962881

@ghost ghost added the S: triage label Mar 9, 2021
@KaelWD
Copy link
Member

KaelWD commented Mar 9, 2021

This seems to be caused by vuejs/vue-test-utils#1661, it works if you roll back to 1.0.4.

@KaelWD KaelWD closed this as completed Mar 9, 2021
@KaelWD KaelWD added testing upstream Problem with a third party library that we may have to work around and removed S: triage labels Mar 9, 2021
@gadelkareem
Copy link
Author

@KaelWD it still fails after downgrade https://gitlab.com/gadelkareem/skeleton/-/jobs/1083837675
plz reopen.

@KaelWD
Copy link
Member

KaelWD commented Mar 9, 2021

You didn't downgrade it, ^ matches the latest minor version.

@gadelkareem
Copy link
Author

Got it! thanks!

gadelkareem added a commit to gadelkareem/skeleton that referenced this issue Mar 9, 2021
gadelkareem added a commit to gadelkareem/skeleton that referenced this issue Mar 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
testing upstream Problem with a third party library that we may have to work around
Projects
None yet
Development

No branches or pull requests

2 participants