Vue Test Utils v2.6.0
vuejs/test-utilsBreaking changes
Summary
Vue Test Utils v2.6.0 introduces a breaking change where plain object and array props are no longer deeply reactive, requiring developers to use `reactive()` for in-place mutations. New features include `TeleportStub`, inferred emitted event names and payload types, and the ability to emit events via `VueWrapper.emit`. Numerous fixes enhance stability and compatibility, particularly with Vue 3.5 and functional components.
Breaking changes in v2.6.0
Plain object and array props are no longer made deeply reactive. Tests relying on in-place mutations must wrap values in reactive() before mounting, or pass a new value to setProps. Passing the same mutated object to setProps does not trigger a re-render. Already-reactive props stay reactive. See #2951 and the migration guidance.
Full release notes
⚠️ Breaking change
Plain object and array props are no longer made deeply reactive. Tests relying on in-place mutations must wrap values in reactive() before mounting, or pass a new value to setProps. Passing the same mutated object to setProps does not trigger a re-render. Already-reactive props stay reactive. See #2951 and the migration guidance.
What's Changed
- feat(types): infer emitted event names and payload types by @niukanen1 in https://github.com/vuejs/test-utils/pull/2948
- feat: add TeleportStub and support custom components as built-in stubs by @simonyang08 in https://github.com/vuejs/test-utils/pull/2946
- feat: add VueWrapper.emit by @ValentinYoushkevich in https://github.com/vuejs/test-utils/pull/2998
- fix: keep the namespace prefix in attributes() by @MaxFreedomPollard in https://github.com/vuejs/test-utils/pull/2941
- fix: store props in shallow reactive to avoid deep propagation by @ackwell in https://github.com/vuejs/test-utils/pull/2951
- fix(types): infer emitted payloads for components with props by @ValentinYoushkevich in https://github.com/vuejs/test-utils/pull/2957
- fix: skip global mocks mixin when mocks are empty by @cexbrayat in https://github.com/vuejs/test-utils/pull/2962
- fix: record emitted events once when a devtools hook is installed by @ValentinYoushkevich in https://github.com/vuejs/test-utils/pull/2965
- fix(types): accept union-typed props in mount by @giaBaoJS in https://github.com/vuejs/test-utils/pull/2967
- fix: find elements and components inside multi-root functional components by @ValentinYoushkevich in https://github.com/vuejs/test-utils/pull/2971
- fix(#2333): keep props from mixins and extends in stubs by @ValentinYoushkevich in https://github.com/vuejs/test-utils/pull/2963
- fix: do not crash stubs on props without primitive conversion by @ValentinYoushkevich in https://github.com/vuejs/test-utils/pull/2975
- fix: support attachTo on Vue versions before 3.5 by @ValentinYoushkevich in https://github.com/vuejs/test-utils/pull/2974
- fix: apply global mocks named after internal instance fields by @ValentinYoushkevich in https://github.com/vuejs/test-utils/pull/2977
- fix: clear events emitted during unmount from the emitted history by @ondrhn in https://github.com/vuejs/test-utils/pull/2985
- fix: findComponent by selector on a functional root component by @ValentinYoushkevich in https://github.com/vuejs/test-utils/pull/2978
- fix: keep Map and Set values in setData by @mkantautas in https://github.com/vuejs/test-utils/pull/2980
- fix: stub directives registered with a camelCase or kebab-case name by @MaxFreedomPollard in https://github.com/vuejs/test-utils/pull/2982
- fix: use Vite mode to select the built package for tests by @cexbrayat in https://github.com/vuejs/test-utils/pull/2995
- fix: update the content of a teleport stubbed with a component by @ValentinYoushkevich in https://github.com/vuejs/test-utils/pull/2993
- fix: do not crash findComponent if ref points to an svg element by @NgoQuocViet2001 in https://github.com/vuejs/test-utils/pull/2983
- fix(stubs): skip component name lookups on re-render by @ondrhn in https://github.com/vuejs/test-utils/pull/2987
- fix(types): keep VueWrapper for findComponent with an any-typed selector by @ondrhn in https://github.com/vuejs/test-utils/pull/2973
- fix(#2541): stub globally registered components by their registration key by @ValentinYoushkevich in https://github.com/vuejs/test-utils/pull/2996
- fix: only apply stubs to the app being rendered by @ValentinYoushkevich in https://github.com/vuejs/test-utils/pull/2997
- fix: infer resolved types for defaulted wrapper props by @mvanhorn in https://github.com/vuejs/test-utils/pull/3003
- fix: render slots passed to a stubbed teleport or keep-alive by @ValentinYoushkevich in https://github.com/vuejs/test-utils/pull/3013
- fix(#2135): do not warn when mounting option slots are called outside render by @ValentinYoushkevich in https://github.com/vuejs/test-utils/pull/3014
New Contributors
- @MaxFreedomPollard made their first contribution in https://github.com/vuejs/test-utils/pull/2941
- @niukanen1 made their first contribution in https://github.com/vuejs/test-utils/pull/2948
- @ackwell made their first contribution in https://github.com/vuejs/test-utils/pull/2951
- @ValentinYoushkevich made their first contribution in https://github.com/vuejs/test-utils/pull/2957
- @Glandos made their first contribution in https://github.com/vuejs/test-utils/pull/2962
- @giaBaoJS made their first contribution in https://github.com/vuejs/test-utils/pull/2967
- @ondrhn made their first contribution in https://github.com/vuejs/test-utils/pull/2985
- @mkantautas made their first contribution in https://github.com/vuejs/test-utils/pull/2980
- @NgoQuocViet2001 made their first contribution in https://github.com/vuejs/test-utils/pull/2983
- @SuperDJ made their first contribution in https://github.com/vuejs/test-utils/pull/3010
Full Changelog: https://github.com/vuejs/test-utils/compare/v2.5.1...v2.6.0