Jest and Cypress AE aren't compatible with Quasar v2 / Vue 3
See original GitHub issuequasar-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:
- Created 3 years ago
- Reactions:3
- Comments:14 (6 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi everyone! A new major version for Cypress testing AE has been released as beta, notable changes:
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
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.