question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`@cypress/vue@4.0.0` bundle is broken: `@vue/test-utils` is not externalized

See original GitHub issue

Current behavior

Currently @cypress/vue (v4) has a dependency:

{
  "dependencies": {
    "@vue/test-utils": "2.0.0-rc.19"
  }
}

But if you explore actual dist/cypress-vue.*.js files, you will see that Vue Test Utils is not imported, but bundled. The only external import is vue.

Desired behavior

@cypress/vue should import @vue/test-utils, not bundle it.

Test code to reproduce

Bundle bug, not test code.

Cypress Version

10

Other

It is a huge problem because our tests rely heavily on setting global Vue Test Utils configuration to achieve global components registration per spec file. (https://test-utils.vuejs.org/api/#config-global)

For example, we do that trick:

import { config } from '@vue/test-utils'
import { mount } from '@cypress/vue'

before(() => {
  config.global.components = { SRadio, SRadioGroup }
})

after(() => {
  config.global.components = {}
})

it('just mounts', () => {
  cy.mount({ template: `<SRadioGroup />` })
})

Now it doesn’t make any effect because mount() from @cypress/vue does not import @vue/test-utils, i.e. it is broken.

BTW, Cypress 10 is awesome!

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:2
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
Akryumcommented, Jul 15, 2022

Looking good

1reaction
lmiller1990commented, Jul 1, 2022

Hi! Good point. If we import it, though, it’s an additional peer dependency, which isn’t really ideal.

We’ve got two options:

  1. try to import it, then defer to bundled version.
  2. bundle it and re-export it

I think 2 is the best option - this way, you just need to update to the latest cypress version, and you’ll get all the updates for free. cypress/vue is generally running against the latest stable test utils version.

This would mean you’d do

import { config, mount } from 'cypress/vue'

Also, if you are on Cypress 10, you don’t even need to install @cypress/vue - we bundle it with Cypress, so just import it from cypress/vue. The goal is, instead of installing lots of different libraries, you just need to install and update Cypress, and we deal with the rest!

What do you think? Open to the first option too, but I think less peer dependencies is generally better for the end user, since you don’t have to mess around with updating everything, just one dependency (cypress).

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found