Performance: Snapshot testing
LOW IMPACT
Snapshot testing affects development and test run speed but does not impact page load or rendering performance in the browser.
import { mount } from '@vue/test-utils'; import MyComponent from './MyComponent.vue'; test('matches snapshot', () => { const wrapper = mount(MyComponent); expect(wrapper.html()).toMatchSnapshot(); });
import { mount } from '@vue/test-utils'; import MyComponent from './MyComponent.vue'; test('renders correctly', () => { const wrapper = mount(MyComponent); expect(wrapper.html()).toBe('<div>Expected HTML here</div>'); });
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Hardcoded HTML string comparison | 0 (test only) | 0 | 0 | [X] Bad for test maintenance speed |
| Snapshot testing with stored output | 0 (test only) | 0 | 0 | [OK] Good for test speed and maintenance |