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

Feature request: respect devtools definition #2310

Closed
webfansplz opened this issue Jan 23, 2024 · 6 comments · Fixed by #2311
Closed

Feature request: respect devtools definition #2310

webfansplz opened this issue Jan 23, 2024 · 6 comments · Fixed by #2311

Comments

@webfansplz
Copy link
Member

webfansplz commented Jan 23, 2024

Is your feature request related to a problem? Please describe.

Hi, Team. I'm the creator of devtools-next. I want to use vuejs/test-utils to test the devtools hook. But I see that there seems to be a polyfill of devtools in the test-utils code. I wonder if it seems like we can add an option to support it? This makes sense for users who want to test the devtools hook functionality. I can submit a PR if it is feasible, thank you.

Describe the solution you'd like

export interface MountingOptions<Props, Data = {}>
  extends BaseMountingOptions<Props, Data> {
  /**
   * Specify where to mount the component.
   * Can be a valid CSS selector, or an Element connected to the document.
   * @see https://test-utils.vuejs.org/api/#attachto
   */
  attachTo?: HTMLElement | string

  /**
   * @default: true
   */
  enableDevtoolsPolyfill?: boolean
}

Describe alternatives you've considered

Additional context

@cexbrayat
Copy link
Member

Hi @webfansplz !

IIRC we just use the COMPONENT_EMIT event to know if an event has been emitted. I don't think we are tied to an implementation of the devtools: we just subscribe to the events emitted by the framework for the devtools. But maybe I'm misunderstanding what you are looking for?

@webfansplz
Copy link
Member Author

Hi @webfansplz !

IIRC we just use the COMPONENT_EMIT event to know if an event has been emitted. I don't think we are tied to an implementation of the devtools: we just subscribe to the events emitted by the framework for the devtools. But maybe I'm misunderstanding what you are looking for?

Hi @cexbrayat !

This is because calling setDevtoolsHook actually overrides the initialization of devtools. See: https://github.com/vuejs/core/blob/HEAD/packages/runtime-core/src/devtools.ts#L52-L53

@cexbrayat
Copy link
Member

Ha OK I understand now 👍

Well TBH, I'm not a fan of adding an option to mount just to test the devtools. Maybe we can find another solution?

@webfansplz
Copy link
Member Author

webfansplz commented Jan 23, 2024

Ha OK I understand now 👍

Well TBH, I'm not a fan of adding an option to mount just to test the devtools. Maybe we can find another solution?

I thought maybe we could add an extra judgment, if globalThis.__VUE_DEVTOOLS_GLOBAL_HOOK__ is already defined (see: https://github.com/vuejs/core/blob/HEAD/packages/runtime-core/src/renderer.ts#L340-L341), we could implement the subscription by overriding its emit method without overwriting the original devtools definition.

@cexbrayat
Copy link
Member

Yeah maybe that could work 👍

@webfansplz webfansplz changed the title Feature request: vue devtools options Feature request: respect devtools definition Jan 23, 2024
@webfansplz
Copy link
Member Author

Yeah maybe that could work 👍

Thank you, I'll submit a PR to support it.

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.

2 participants