Maiquu / nuxt-quasar

Quasar Module for Nuxt (Unofficial)
MIT License
153 stars 9 forks source link

[BUG] - Vitest support? #38

Open frisch-raphael opened 1 year ago

frisch-raphael commented 1 year ago

Checks

Environment

Quasar version

2.11.10

Browsers

Other

Description

First of all thanks a lot for your work. Sorry if that's not the right place to ask, as it is not really a bug, but is vitest testing supported for quasar components? I've been trying for a few hours to integrate vitest but to no avail yet. I tried several things, from using installQuasarPlugin() as per this documentation https://github.com/quasarframework/quasar-testing/tree/dev/packages/unit-vitest

Also tried to follow the answer on this stackoverflow post : https://stackoverflow.com/questions/71486252/vitest-integration-with-quasar

But I figured it works differently since it's not Quasar per see we're using.

import { DataIds } from '~~/tests/data-ids'
import { mount, VueWrapper } from '@vue/test-utils'
import { selector } from '~~/tests/test-utils'
import TileCard from '~~/components/layout/resource/TileCard.vue'
import { mockEngagements } from '~~/dtos/engagement.mock'
import { engagementColumns } from '~~/components/layout/engagement/table/engagement-table-columns'
// import { installQuasarPlugin } from '@quasar/quasar-app-extension-testing-unit-vitest'
// installQuasarPlugin()
let wrapper: VueWrapper<any>
describe('the TileCard', () => {
  beforeEach(() => {
    wrapper = mount(TileCard, {
      props: {
        resource: mockEngagements[0],
        columns: engagementColumns
      }
    })
  })

  test('checkbox works', () => {
    const html = wrapper.html()
    console.debug(html) 
// <q-card bordered="" flat="" class="">
//    <q-card-section>
//     <q-checkbox dense="" modelvalue="false" data-id="resource-tile-card-checkbox"></q-checkbox>
//    </q-card-section>
//    <q-separator></q-separator>
//    <q-list dense="">
// ...
//  ^---------- i'm not getting the full html of the quasar components
  })
})

Any direction I should go ?

Reproduction steps

1. Install Vitest
2. Try to test a component that contains quasar components

Screenshots

Here's what I get when I try to use installQuasarPlugin() at the top of the file. image

Logs

No response

Maiquu commented 1 year ago

I suggest you checkout nuxt-vitest if you are trying to test components in nuxt environment.

Maiquu commented 1 year ago

Will keep the issue open until I can provide a example.