-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@cypress/vue@4.0.0
bundle is broken: @vue/test-utils
is not externalized
#22611
Comments
@vue/test-utils
is not externalized@cypress/vue@4.0.0
bundle is broken: @vue/test-utils
is not externalized
Hi! Good point. If we import it, though, it's an additional peer dependency, which isn't really ideal. We've got two options:
I think 2 is the best option - this way, you just need to update to the latest 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 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). |
At least if we can access the |
One of the issues to consider with either solution is that @Akryum what do you need from the exports object that you cannot set when invoking mount itself? The before/after syntax in the initial code example of this issue is useful, but it's entirely possible to just pass in |
I am working on this, it should be done soon. Edit: I made this PR #22757 What do you all think of this API? Basically, we just re-export import { VueTestUtils, mount } from 'cypress/vue'
import Foo from './Foo.vue'
describe('VueTestUtils API', () => {
before(() => {
VueTestUtils.config.global.components = {
'globally-registered-component': {
setup () {
return () => h('h1', greeting)
},
},
}
})
it('gains access to underlying Vue Test Utils library', () => {
mount(Foo)
cy.get('h1').contains(greeting)
})
}) There's probably some edge cases, and certain APIs between Test Utils v1 and v2 are different, so regarding docs, I think we'd just say " I've also inlined the Test Utils type definitions, so those should be working (even for users with the |
The PR is ready to go. @Akryum will this solve your problem? |
Looking good |
Current behavior
Currently
@cypress/vue
(v4) has a dependency: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 isvue
.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:
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!
The text was updated successfully, but these errors were encountered: