No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    1. Home
    2. a11dev
    A
    • Profile
    • Following 0
    • Followers 0
    • Topics 0
    • Posts 1
    • Best 0
    • Groups 0

    a11dev

    @a11dev

    0
    Reputation
    1
    Profile views
    1
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    a11dev Follow

    Latest posts made by a11dev

    • RE: @quasar/testing (jest) components not registered when VueRouter not created

      Hi, new to unit test so I lack some experience, I’m also struggling with router/q-page unit test, but seems I am able to not come across your problem, hoping will help.
      I set up the test starting from quasar doc for Jtest, so I have my "test\jest_tests_\App.spec where, this is the code ( I’ve deleted some test automatically generated by quasar cli );
      It seems I overcome your problem, still I’ve problems because using the real router instead a mock, router.js import fails because of the base dir.
      I’m look over it trying finding out how solve this problem.

      ==================
      App.spec.js

      import { mount, createLocalVue, shallowMount } from ‘@vue/test-utils’
      import QBUTTON from ‘./demo/QBtn-demo.vue’
      import * as All from ‘quasar’
      import VueRouter from ‘vue-router’
      import mypage from ‘…/…/…/src/pages/MyPage.vue’
      import routes from ‘…/…/…/src/router/routes.js’
      import App from ‘…/…/…/src/App.vue’
      // import langEn from ‘quasar/lang/en-us’ // change to any language you wish! => this breaks wallaby 😞
      const { Quasar } = All

      const components = Object.keys(All).reduce((object, key) => {
      const val = All[key]
      if (val && val.component && val.component.name != null) {
      object[key] = val
      }
      return object
      }, {})

      describe(‘Mount Quasar’, () => {
      const localVue = createLocalVue()
      localVue.use(Quasar, { components }) // , lang: langEn
      localVue.use(VueRouter)

      const wrapper = mount(QBUTTON, {
      localVue
      })
      const vm = wrapper.vm

      […]

      it(‘render MyPage via ruting’, () => {
      const router = new VueRouter({ routes })
      const wrapper = mount( App, { localVue, router })
      router.push(’/mypage’)
      expect(wrapper.findComponent(mypage).exists()).toBe(true)
      })
      })

      ====================
      router.js

      const routes = [
      {
      path: ‘/’,
      component: () => import(‘layouts/MainLayout.vue’),
      children: [
      { path: ‘’, component: () => import(‘pages/Index.vue’) },
      {
      path: ‘/mypage’,
      component: () => import(‘pages/MyPage.vue’)
      }
      ]
      },

      // Always leave this as last one,
      // but you can also remove it
      {
      path: ‘*’,
      component: () => import(‘pages/Error404.vue’)
      }
      ]

      export default routes

      posted in [v1] App Extensions
      A
      a11dev