bulky-sundown-74498
06/28/2021, 4:22 PMbulky-sundown-74498
06/28/2021, 4:22 PMsalmon-oyster-49557
06/28/2021, 4:23 PMbulky-sundown-74498
06/28/2021, 4:24 PMbulky-sundown-74498
06/28/2021, 4:24 PMsalmon-oyster-49557
06/28/2021, 4:25 PMsalmon-oyster-49557
06/28/2021, 4:27 PMsalmon-oyster-49557
06/28/2021, 4:39 PM<App>
of the project: <div id="app">
and <ion-page>
. So far it has always been a blank page, visually.bulky-sundown-74498
06/28/2021, 4:40 PMbulky-sundown-74498
06/28/2021, 4:40 PMbulky-sundown-74498
06/28/2021, 4:41 PMsalmon-oyster-49557
06/28/2021, 4:41 PMbulky-sundown-74498
06/28/2021, 4:55 PMsalmon-oyster-49557
06/28/2021, 4:57 PMbulky-sundown-74498
06/28/2021, 4:58 PMbulky-sundown-74498
06/28/2021, 4:58 PMsalmon-oyster-49557
06/28/2021, 5:01 PMbulky-sundown-74498
06/28/2021, 5:02 PMbulky-sundown-74498
06/28/2021, 5:02 PMsalmon-oyster-49557
06/28/2021, 5:02 PM...spec.cy.ts
instead of ...spec.ts
salmon-oyster-49557
06/28/2021, 5:03 PMsalmon-oyster-49557
06/29/2021, 4:38 PM<ion-page>
to wrap elements for them to be visible or show up properly.
Is there a clean way to provide a "test bed" or "playground" to mount a component into?bulky-sundown-74498
06/29/2021, 5:08 PMmount(() => <ion-page><comp></ion-page>, options)
?salmon-oyster-49557
06/29/2021, 5:10 PMsalmon-oyster-49557
06/30/2021, 3:29 AMcypress/ct/support/commands.js
to commands.tsx
- Wrapped the component passed into the new mount
in <IonPage>
- Moved props to the options, using the now recommended data: => ({})
key on options
Here's my `commands.tsx`:
import { mount } from "@cypress/vue"
import { IonicVue, IonPage } from '@ionic/vue'
Cypress.Commands.add('ionPageMount', (comp, options) => {
options = options || {}
options.global = options.global || {}
options.global.plugins = options.global.plugins || []
options.global.plugins.push(IonicVue)
const data = options.data ? options.data() : {}
return mount(<IonPage><comp { ...data } /></IonPage>, options)
})
declare global {
namespace Cypress {
interface Chainable {
ionPageMount: typeof mount;
}
}
}
And here it is in use:
it('renders with props', () => {
cy.ionPageMount(ExploreContainer, {
data: () => ({
name: 'ExploreContainer title'
})
})
const data = options.data ? options.data() : {}
would be prettier with optional chaining, but it wasn't being picked up for this file 🤷 so I kept it simple.salmon-oyster-49557
06/30/2021, 3:32 AMsalmon-oyster-49557
06/30/2021, 4:24 AMancient-appointment-66951
07/02/2021, 12:06 PMancient-appointment-66951
07/02/2021, 12:06 PMancient-wire-34126
07/07/2021, 1:11 PM