https://cypress.io logo
Join Discord
Powered by
# vue
  • b

    bulky-sundown-74498

    06/28/2021, 4:22 PM
    It could be that you need to wrap every component in ionics context
  • b

    bulky-sundown-74498

    06/28/2021, 4:22 PM
    I do not know ionic enough just yet
  • s

    salmon-oyster-49557

    06/28/2021, 4:23 PM
    Have you seen anyone do CT with Ionic, yet? I wonder if there's something missing from the way it's set up in terms of e2e vs CT, because I either can't see any styles, or I can't see anything even with the styles present.
  • b

    bulky-sundown-74498

    06/28/2021, 4:24 PM
    To your first question no, you are the first we are in beta and @User is working as fast as he can to make examples for all frameworks
  • b

    bulky-sundown-74498

    06/28/2021, 4:24 PM
    Give me a minute to figure out the styles on the PR I gave you
  • s

    salmon-oyster-49557

    06/28/2021, 4:25 PM
    You are wonderful, thank you ❤️
  • s

    salmon-oyster-49557

    06/28/2021, 4:27 PM
    For examples, lmk if I can help. Here's what I'm using (newest of the new) in case it is useful for examples: - Typescript - Ionic 5, targeting Android and iOS - Vue 3 - Capacitor 3 (just released) - Pinia 2 (Vuex is so much typing...)
  • s

    salmon-oyster-49557

    06/28/2021, 4:39 PM
    Btw, as you can see in my attempt to set up style imports here https://github.com/codeluggage/ionic-5-vue-3-cypress-ct-and-e2e-combined/blob/main/cypress/ct/support/index.js#L23, the styles do end up in the nested html of the component of the test. However, something is clearly missing. What you mention about "wrap every component in ionics context" sounds like a good lead. I've naively tried to wrap the component I was testing in anything I could find in the root
    <App>
    of the project:
    <div id="app">
    and
    <ion-page>
    . So far it has always been a blank page, visually.
  • b

    bulky-sundown-74498

    06/28/2021, 4:40 PM
    The issue is incredibly simple
  • b

    bulky-sundown-74498

    06/28/2021, 4:40 PM
    The ionic plugin is not used so the .hydrated class is never added to body
  • b

    bulky-sundown-74498

    06/28/2021, 4:41 PM
    GIve me one more split second to wrap a mount vue nice
  • s

    salmon-oyster-49557

    06/28/2021, 4:41 PM
    You wizard 🙂
  • b

    bulky-sundown-74498

    06/28/2021, 4:55 PM
    done
  • s

    salmon-oyster-49557

    06/28/2021, 4:57 PM
    Thank you! I was exploring this direction, looking at some of the examples from earlier in this channel. Still don't grok it at all.
  • b

    bulky-sundown-74498

    06/28/2021, 4:58 PM
    now, use cy.mount
  • b

    bulky-sundown-74498

    06/28/2021, 4:58 PM
    it will do all you need
  • s

    salmon-oyster-49557

    06/28/2021, 5:01 PM
    e2e and CT living happily together in Ionic-Vue land - beautiful 😍 For posterity, if you come here looking for the built in end to end testing in Ionic-Vue (Vue 3, Ionic 5) working alongside the new Cypress 7.0+ component testing, there's a working example in https://github.com/codeluggage/ionic-5-vue-3-cypress-ct-and-e2e-combined
  • b

    bulky-sundown-74498

    06/28/2021, 5:02 PM
    note as well, that I changed the template for the filename
  • b

    bulky-sundown-74498

    06/28/2021, 5:02 PM
    It's mostly because of potential type and lint conflicts with Jest
  • s

    salmon-oyster-49557

    06/28/2021, 5:02 PM
    Yes,
    ...spec.cy.ts
    instead of
    ...spec.ts
  • s

    salmon-oyster-49557

    06/28/2021, 5:03 PM
    👍 I'm removing Jest, next.
  • s

    salmon-oyster-49557

    06/29/2021, 4:38 PM
    @User Looks like Ionic-Vue requires
    <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?
  • b

    bulky-sundown-74498

    06/29/2021, 5:08 PM
    There is not... not yet at least @User was talking about adding one to the vue-test-utils. I wonder if he has done it yet. In the meantime, how about using jsx like so
    mount(() => <ion-page><comp></ion-page>, options)
    ?
  • s

    salmon-oyster-49557

    06/29/2021, 5:10 PM
    Ah, thank you! I was trying to get this working this very second. Return as a function, got it.
  • s

    salmon-oyster-49557

    06/30/2021, 3:29 AM
    As a follow up on wrapping components for Ionic-Vue in the required elements, this is what I ended up with: - Changed
    cypress/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`:
    Copy code
    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:
    Copy code
    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.
  • s

    salmon-oyster-49557

    06/30/2021, 3:32 AM
    Thanks again for the PR and help @User ! I'll update the example repo with this (and removing any trace of jest) for posterity, and in case it's useful for either of your work @User @User. PS: It was your videos that opened my eyes to how great Cypress is @User - your content is magnificent! 🙏
  • s

    salmon-oyster-49557

    06/30/2021, 4:24 AM
    Updated the repo with a setup guide, example and properly wrapping with `IonPage`: https://github.com/codeluggage/ionic-5-vue-3-cypress-ct-and-e2e-combined
  • a

    ancient-appointment-66951

    07/02/2021, 12:06 PM
    thanks!!!!!
  • a

    ancient-appointment-66951

    07/02/2021, 12:06 PM
    Glad you are finding Cypress and the content useful!!
  • a

    ancient-wire-34126

    07/07/2021, 1:11 PM
    I have the weirdest issue which kind of doesn't fit any real category: When we install cypress, it installs a bunch of deps (of course), including a bunch of react-native ones that in turn install babel-core@7. This, for some reason, throws "jest-haste-map" errors in our Jest unit tests haha. I have a feeling something like vue-test-utils clashes with cypress' dependencies but that seems... weird. I can consistently reproduce it (by removing/adding cypress) and afaict our unit tests and cypress have nothing to do with each other (we're actually not even using Cypress at all)
1...272829...37Latest