cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
46.96k stars 3.18k forks source link

Vue 3 component in slot doesn't load #29215

Open RoccoDevs opened 7 months ago

RoccoDevs commented 7 months ago

Current behavior

I have a cypress component test, this test worked before my migration to vue 3. The test added a component through the slots mount option. After migrating to vue 3 that functionality no longer works. Is this expected behaviour? I have included a test project where I try to do the same. Simply open cypress and run the component test.

I have tried various ways of importing the component, like defining the components with names but none seem to work.

The slots get added through mount:

import HelloWorld from '../HelloWorld.vue'
import TheWelcome from '../TheWelcome.vue'

describe('HelloWorld', () => {
  it('playground', () => {
    cy.mount(HelloWorld, {
      props:
        {
          msg: 'Hello Cypress'
        } ,
      slots: {
        default: '<TheWelcome></TheWelcome>'
      }
    })
    cy.get('h1').should('contain', 'Sub component')
  })
})

Desired behavior

Cypress properly adds the vue 3 requirements to load in the component.

Test code to reproduce

https://github.com/RoccoDevs/vue-slots-cypress

Cypress Version

13.7.1

Node version

20.11.1

Operating System

Windows 11 23H2

Debug Logs

No response

Other

No response

thevladisss commented 6 months ago

You can definitely use "h" function from "vue" package that would let you render this component. I would assume this problem is caused by the absence of runtime template compiler that cannot render the component is slot

cypress-app-bot commented 1 week ago

This issue has not had any activity in 180 days. Cypress evolves quickly and the reported behavior should be tested on the latest version of Cypress to verify the behavior is still occurring. It will be closed in 14 days if no updates are provided.