Skip to content
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

Proposal: Hook to override default stub creation #1216

Closed
freakzlike opened this issue Jan 5, 2022 · 0 comments · Fixed by #1241
Closed

Proposal: Hook to override default stub creation #1216

freakzlike opened this issue Jan 5, 2022 · 0 comments · Fixed by #1241

Comments

@freakzlike
Copy link
Collaborator

As mentioned in #1174 (comment). I want to be able to customize the default creation of a stubbed component, when using shallowMount or stubs: { ChildComponent: true }.

This could look something like:

const wrapper = shallowMount(MyComponent, {
  global: {
    createStubs: ({ name, component }) => {
      // Implement own logic to create a stub
      return defineComponent({
        name,
        render: () => // Custom render logic
      })
    }
  }
})

If set the hook would be called once for every component instead of createStub.
https://github.com/vuejs/vue-test-utils-next/blob/5bfe95cc71f6d07aff576a66bf450e6f23a26a36/src/stubs.ts#L282-L288

Unfortunately I was not able to find another way, without manually create a stub for every component. I tried to use transformVNodeArgs by myself but it will be replaced when I do mount.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant