Performance: Component testing with Vue Test Utils
LOW IMPACT
Component testing affects development speed and feedback loop but can indirectly impact runtime performance by catching inefficient rendering patterns early.
import { mount } from '@vue/test-utils' import MyComponent from './MyComponent.vue' test('renders with final prop value only', async () => { const wrapper = mount(MyComponent) await wrapper.setProps({ count: 99 }) expect(wrapper.text()).toContain('99') })
import { mount } from '@vue/test-utils' import MyComponent from './MyComponent.vue' test('renders and updates DOM repeatedly', async () => { const wrapper = mount(MyComponent) for(let i = 0; i < 100; i++) { await wrapper.setProps({ count: i }) } expect(wrapper.text()).toContain('99') })
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Multiple prop updates in loop | Many DOM patches | 100 reflows | High paint cost | [X] Bad |
| Single prop update before assertion | One DOM patch | 1 reflow | Low paint cost | [OK] Good |