Repository navigation
fix(#2541): stub globally registered components by their registration key - #2996
Open
ValentinYoushkevich wants to merge 1 commit into
Open
ValentinYoushkevich wants to merge 1 commit into
ValentinYoushkevich wants to merge 1 commit into
Conversation
…ation key A component registered with app.component() under a key that differs from its name could only be stubbed by its name. Also match the key from the app registry, between the local registration key and the name, using a map built once per app.
✅ Deploy Preview for vue-test-utils-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
commit: |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A component registered with
app.component()under a key that differs from itsname(naive-ui registersButtonasNButton, Arco asAButton) can't be stubbed by that key:The stubs transformer only matched the key of locally registered components (
instance.type.components) and the component name. It now also matches the key from the app registry (appContext.components), between those two, like Vue resolves components. A map from component to stub key is built once per app, so this doesn't add a lookup per stub on every render. Stubs thatshallowMountcreates for components not listed instubskeep their name (button-stub); a listed key now names the stub (n-button-stub), as for local registrations. The same fix makesfalsework undershallowfor a registration key that doesn't match the name: before, the name lookup ran next and overwrote it.Real code that works around it by stubbing the internal name: wnzzer/rank-analysis Automation.tierSelect.spec.ts#L26-L32. With
NSelectas the key, that spec fails on 2.5.1 and main and passes with this change.Playground (2.5.1)
Fixes #2541