Performance: Mounting components (mount vs shallow)
MEDIUM IMPACT
This affects the initial rendering speed and memory usage during component testing by controlling how deeply components are rendered.
import { shallowMount } from '@vue/test-utils'; import ParentComponent from './ParentComponent.vue'; const wrapper = shallowMount(ParentComponent);
import { mount } from '@vue/test-utils'; import ParentComponent from './ParentComponent.vue'; const wrapper = mount(ParentComponent);
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| mount | Full DOM tree including children | Multiple reflows proportional to child count | High paint cost due to complex tree | [X] Bad |
| shallow | Only parent component DOM nodes | Single reflow | Low paint cost | [OK] Good |