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

    some-air-72294

    04/14/2021, 7:25 PM
    cool. i can create more public examples after finishing each private project section and then add them. Right now i have to finish a bunch of individual components....then i can add examples for those, then i'll be making some for views and make examples for those. At work is where i'm working on them the most but i still spend a lot of time outside of work messing with similar projects. I don't do any articles or blog post but can try to look out more for questions on stackoverflow and github issues
  • s

    stocky-dream-36427

    04/14/2021, 7:26 PM
    Yeah. That's great stuff.
  • s

    stocky-dream-36427

    04/14/2021, 7:26 PM
    You using the project is the BEST thing you can do
  • s

    stocky-dream-36427

    04/14/2021, 7:26 PM
    and if you are active in this chat, that's also very valuable 🙂
  • s

    stocky-dream-36427

    04/14/2021, 7:27 PM
    Happy to have you around. LMK if you need anything else
  • s

    some-air-72294

    04/14/2021, 7:28 PM
    Thank you! glad to be here and thanks again to you and @User for helping me get started using this with nuxt
  • r

    rich-address-79346

    04/14/2021, 8:30 PM
    Great talk @User - I have one more question: So when it comes to Vuetify, I am used to mock/set-up a lot of stuff just to being able to test my components that consist of other vuetify components. How about Cypress? Is the amount of mocking/setting-up the same?
  • r

    rich-address-79346

    04/14/2021, 8:30 PM
    Like do I still need to import all the used Vuetify components, initialize Vuetify, etc. ?
  • r

    rich-address-79346

    04/14/2021, 8:30 PM
    @User
  • s

    stocky-dream-36427

    04/14/2021, 8:35 PM
    @User You do need to do all the same setup
  • s

    stocky-dream-36427

    04/14/2021, 8:36 PM
    Essentially, each component is a root level that is either passed to createApp (Vue 3) or to new Vue() (Vue 2)
  • s

    stocky-dream-36427

    04/14/2021, 8:36 PM
    I always make a wrapped
    mount
    function inside of a helpers file and I use that helper exclusively. I never use the "raw" mount function if I'm doing anything that contains plugins/app setup. These wrapper functions setup the proper plugins, such as Vuetify, and then I never have to think about it again.
  • s

    stocky-dream-36427

    04/14/2021, 8:37 PM
    Cypress also lets you register custom commands. I've used this to make a
    cy.mount
    command which contains the Vue-level
    mount
    but also pipes through all of my Vuetify/Vuex/Vue Router setup, etc
  • s

    stocky-dream-36427

    04/14/2021, 8:38 PM
    This is a best practice even if you are not using Cypress. I recommend this for vanilla Vue Test Utils code
  • r

    rich-address-79346

    04/14/2021, 8:39 PM
    @User true! Alright, good to know. Thank you very much for this detailed answer 👍
  • r

    red-refrigerator-13075

    04/14/2021, 8:47 PM
    Hi! 👋 , does any of you have a problem loading the styles of a SFC when using cypress ct with Vue?
  • s

    stocky-dream-36427

    04/14/2021, 8:48 PM
    Hey @User this is because your main.css or index.css is targeting #app yeah?
  • r

    red-refrigerator-13075

    04/14/2021, 8:48 PM
    Here is the repo https://github.com/xanxuz/vue-cypress-ct
  • s

    stocky-dream-36427

    04/14/2021, 8:49 PM
    So this https://github.com/xanxuz/vue-cypress-ct/blob/main/src/App.vue#L20-L27
  • s

    stocky-dream-36427

    04/14/2021, 8:50 PM
    there's a general rule when component testing: You need to make sure your app's environments (CSS Resets, icons, global styles, etc) are all applied and targeting your app's container.
  • r

    red-refrigerator-13075

    04/14/2021, 8:50 PM
    You are right 😅 . what should I do to make it work Jess?
  • s

    stocky-dream-36427

    04/14/2021, 8:50 PM
    So for example, you have an component that sets up "global" styles for your application.
  • s

    stocky-dream-36427

    04/14/2021, 8:51 PM
    Personally, the first thing I do is make a "main.css" file and anything that is global that needs to be part of every setup needs to go in there
  • s

    stocky-dream-36427

    04/14/2021, 8:51 PM
    So any CSS resets, or any default fonts, those go in there
  • b

    bulky-sundown-74498

    04/14/2021, 8:51 PM
    @User I am cloning your repo as we speak
  • b

    bulky-sundown-74498

    04/14/2021, 8:51 PM
    double checking what we say
  • s

    stocky-dream-36427

    04/14/2021, 8:52 PM
    Yeah we'll give you a PR onto it, but... essentially your "support.js" file is going to be where you setup your application's global state
  • s

    stocky-dream-36427

    04/14/2021, 8:52 PM
    anything you need to do on window, or with styles... that happens in there. So you'd do
    Copy code
    import './main.css'
  • s

    stocky-dream-36427

    04/14/2021, 8:52 PM
    and that would give you all of your global styles
  • s

    stocky-dream-36427

    04/14/2021, 8:52 PM
    There are other approaches, but that is my recommended one
1...141516...37Latest