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.

Jest and Cypress AE aren't compatible with Quasar v2 / Vue 3

See original GitHub issue

quasar-testing needs to be updated for Quasar v2 / Vue3. I’ve created this issue just to track things I’ve discovered while trying to get unit testing to work for components using Quasar v2.

  • Several components (QPage, QHeader etc.) require a layout. The layout is accessed via provide/inject by the layoutKey symbol declared in utils/private/symbols.js. These symbols are not exported by Quasar, so it’s not possible to injected a layout stub from within a unit test. The only solution I could come up with is to either export these symbols in Quasar or at least to create them with Symbol.for() to allow to use them in the unit tests. This is a minimal passing test case for a component using QPage:
import { mount } from '@vue/test-utils'
import { defineComponent } from 'vue'
import { QPage } from 'quasar'

const Component = defineComponent({
  template: '<QPage><div>Test</div></QPage>',
  components: {
    QPage
  },
  setup() {
    return {

    }
  }
})

describe('component', () => {
  it('renders the template', () => {
    const wrapper = mount(Component, {
      global: {
        provide: {
          [Symbol.for('_q_l_')]: {
              header: {},
              footer: {},
              right: {},
              left: {},
              isContainer: {
                value: true
              },
              containerHeight: {
                value: 100
              }
          }
        }
      }
    })
    expect(wrapper.find("div").text()).toBe("Test")
  })
})

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:14 (6 by maintainers)

github_iconTop GitHub Comments

7reactions
IlCallocommented, Jun 3, 2021

Hi everyone! A new major version for Cypress testing AE has been released as beta, notable changes:

  • support Qv2, drop Qv1
  • updated Cypress to 7.x
  • Quasar helper commands and related types are now exported directly from the package

See release notes here: https://github.com/quasarframework/quasar-testing/releases/tag/4.0.0-beta.1

I’ll rename the issue to let everyone know only Jest is missing now.


For Jest testing AE things are more complicated, but the new version will come in some weeks too

5reactions
IlCallocommented, Apr 27, 2021

I thought comments in other issues and on the ROADMAP were already clear, but I’ll explicitly state it again:

Testing AE still hasn’t been migrated to Qv2 / Vue3

We were pretty busy finalising Qv2 stable release, which will come soon 😃 I plan to work on this in May.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Jest | quasar-testing
Jest isn't compatible with Vite, if you use @quasar/app-vite and you need unit testing, you should use Vitest instead. This package is in...
Read more >
@quasar/quasar-app-extension-testing-unit-jest | Yarn - Yarn
App Extensions (such as these testing harnesses) only work with Quasar CLI, not with Vue CLI, nor by directly installing packages via a...
Read more >
vue.js - Quasar unit testing for vue3 - Stack Overflow
I am using vue 3.0.7. I have installed jest and created the jest.config File. The jest config file contains the following: clearMocks: true, ......
Read more >
Jest AE v2.2.0 and Cypress AE v3.0.0 released! - Quasar forum
Jest harness v2.2.0 has been released with some fixes for monorepo setups, check it out!
Read more >
Getting Started with Cypress Component Testing (Vue 2/3)
Discussion. The Cypress Component Test Runner is an alternative to a jsdom based testing environment, such as Jest and Vue Test Utils. Cypress...
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