Skip to content
This repository was archived by the owner on Nov 26, 2021. It is now read-only.
This repository was archived by the owner on Nov 26, 2021. It is now read-only.

Cannot read property 'runtime' of undefined in unit tests #832

@VladZen

Description

@VladZen

I have a problem in my unit tests only:

TypeError: Cannot read property 'runtime' of undefined
at ModuleCollection.unregister (node_modules/vuex/dist/vuex.common.js:219:28)
      at Store.unregisterModule (node_modules/vuex/dist/vuex.common.js:512:17)
      at Object.<anonymous>.module.exports (node_modules/vue-tables-2/compiled/state/register-module.js:19:17)
      at Object.<anonymous>.module.exports (node_modules/vue-tables-2/compiled/mixins/created.js:9:5)
      at VueComponent.created (node_modules/vue-tables-2/compiled/v-server-table.js:65:7)

After some research I figured out that users are stuck with the same problem using SSR. For example, vuejs/vue2-ssr-docs#137 (comment) . Diving deeper I discovered that It also can be rooted from the dynamic registration of the vuex module inside created hook instead of beforeCreate

Possible solutions:

  1. if (self.$store && self.$store.state && self.$store.state[self.name]) {

    I suppose it could be better to check out the existence of the registered module using https://vuex.vuejs.org/api/#hasmodule

  2. Move the registration of the module inside beforeCreate instead of created

These all things are just assumptions. I will try to test them and let you know if I come up with something.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions