vuejs / test-utils

Vue Test Utils for Vue 3
https://test-utils.vuejs.org
MIT License
1.04k stars 244 forks source link

chrome will remove `DOMXXX` event listeners on July 30 #2449

Open userquin opened 5 months ago

userquin commented 5 months ago

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

Running Vitest Browser 2.0 beta 5 on tresjs test I can see a lot of warnings from chrome in the console about relying on DOMXXX event listeners:

imagen

The example can be found here: https://github.com/Tresjs/tres/pull/715

Describe the solution you'd like

Here the link https://chromestatus.com/feature/5083947249172480 .

Describe alternatives you've considered

None

Additional context

NA

cexbrayat commented 5 months ago

Hi @userquin

VTU listens to all possible DOM events (see dom-events.ts), so I think this warning is expected, and probably not a big deal (if you don't use these events yourself in your application).

Maybe we can remove them in a future VTU version to avoid the warnings and hope that this won't break tests out there that rely on these.

If you're willing to, a PR would be most welcome.

IlCallo commented 2 months ago

This message is spammed in every Cypress component test, unluckily More a nuisance than a real problem

cexbrayat commented 2 months ago

@IlCallo A PR to fix this should be fairly simple and greatly appreciated 👍

IlCallo commented 2 months ago

Why is VTU listining for those events in the first place? Just to allow devs to listen to them in their tests? Or are they actually used by the library?

cexbrayat commented 2 months ago

Yes, VTU listens to all possible events to record them and allow developers to check them with wrapper.emitted() (see vueWrapper.ts)

https://github.com/vuejs/test-utils/blob/582d7d7bc7d86babbdd3c13de2f7150b80686e84/src/vueWrapper.ts#L200-L209

This code was probably the same in VTU v1. I started helping with the maintenance after this was written so I don't know why this design was picked.

Anyway, I think removing the culprit events from dom-events.ts should be enough. This means developers won't be able to check them with emitted() but as these events are getting deprecated, I suppose it's fine.