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

    little-shampoo-74692

    04/15/2021, 4:25 PM
    import {i18n} from './plugins/i18n'
  • r

    red-refrigerator-13075

    04/15/2021, 4:25 PM
    Ok I'll try it, but, that workaround would be in cypress docs?, other Vue developers will have the same issue
  • l

    little-shampoo-74692

    04/15/2021, 4:27 PM
    I think this goes in the main.js file. It may not work, but I think that will solve the issue for _t
  • r

    red-refrigerator-13075

    04/15/2021, 4:27 PM
    Hi Bryan, Did you check the example repo? https://github.com/xanxuz/vue-cypress-ct
  • l

    little-shampoo-74692

    04/15/2021, 4:27 PM
    I did.
  • l

    little-shampoo-74692

    04/15/2021, 4:28 PM
    I'm looking over this issue as a whole, so I may have missed some details.
  • l

    little-shampoo-74692

    04/15/2021, 4:30 PM
    import i18n from './translations';
  • l

    little-shampoo-74692

    04/15/2021, 4:30 PM
    This might work in the App.vue file instead. I'd try both.
  • l

    little-shampoo-74692

    04/15/2021, 4:30 PM
    (Separately)
  • r

    red-refrigerator-13075

    04/15/2021, 4:30 PM
    Ok, I tried to import the i18n file in the cypress/support file (the one with "Vue.use(Vuei18n)" ) to check if that way could work but it didn't. The i18 file has this:
  • b

    bulky-sundown-74498

    04/15/2021, 4:31 PM
    @User the instance of Vue used in mount is not the one exxposed in import Vue
  • b

    bulky-sundown-74498

    04/15/2021, 4:31 PM
    This avoids having to do some painful teardown after each it
  • b

    bulky-sundown-74498

    04/15/2021, 4:32 PM
    But it's more complicated than it seems to use plugins
  • l

    little-shampoo-74692

    04/15/2021, 4:33 PM
    Sorry. What about line 4 in main.js?
  • b

    bulky-sundown-74498

    04/15/2021, 4:34 PM
    This will have no effect on the mounted component since cypress mount uses a localVue instance
  • b

    bulky-sundown-74498

    04/15/2021, 4:35 PM
    So this line will install i18n on the globally exposed Vue instance... but mount is not using this instance.
  • b

    bulky-sundown-74498

    04/15/2021, 4:38 PM
    This is why you have to create the mounti18n function
  • u

    user

    04/15/2021, 4:38 PM
    Maybe?
    Copy code
    js
    import { i18n } from '<your_path>/i18n';
    ...
    mount(Component, {
      ...,
      i18,
      ...
    })
  • b

    bulky-sundown-74498

    04/15/2021, 4:38 PM
    You should even probably create a mount that sets up all your plugins as needed
  • l

    little-shampoo-74692

    04/15/2021, 4:39 PM
    What about the export from vue-cypress-ct/src/plugins/i18n.js
  • l

    little-shampoo-74692

    04/15/2021, 4:39 PM
    This is a 'new' instance instead of the actual component.
  • r

    red-refrigerator-13075

    04/15/2021, 4:39 PM
    So the only way for now to affect all tests is creating a helper function of mount?, I thought that the support file was for that case.
  • b

    bulky-sundown-74498

    04/15/2021, 4:39 PM
    https://giphy.com/gifs/chelsiekenyon-chelsie-kenyon-up-there-hs1npjzqJCe0Y2wNV6
  • b

    bulky-sundown-74498

    04/15/2021, 4:40 PM
    The support file is only loading stuff outside of Vue
  • b

    bulky-sundown-74498

    04/15/2021, 4:40 PM
    if you want to influence the instance of Vue, you have to do it using a wrapper function
  • l

    little-shampoo-74692

    04/15/2021, 4:40 PM
    Yep.
  • r

    red-refrigerator-13075

    04/15/2021, 4:40 PM
    If you put that in a helper function as @User mentioned yes, but doing that per each test file is not viable.
  • b

    bulky-sundown-74498

    04/15/2021, 4:40 PM
    It has big advantages if you ask me
  • l

    little-shampoo-74692

    04/15/2021, 4:41 PM
    Yeah. Looking at it a little deeper this makes sense.
  • b

    bulky-sundown-74498

    04/15/2021, 4:41 PM
    It makes setup more explicit (plus if you are using typescript you can use F12 to follow what is happening)
1...171819...37Latest