Performance: Testing async behavior
MEDIUM IMPACT
This affects the responsiveness and smoothness of user interactions during asynchronous operations in Vue components.
import { mount } from '@vue/test-utils'; import MyComponent from './MyComponent.vue'; test('good async test', async () => { const wrapper = mount(MyComponent); await wrapper.vm.fetchData(); await wrapper.vm.$nextTick(); expect(wrapper.text()).toContain('Loaded Data'); });
import { mount } from '@vue/test-utils'; import MyComponent from './MyComponent.vue'; test('bad async test', () => { const wrapper = mount(MyComponent); wrapper.vm.fetchData(); expect(wrapper.text()).toContain('Loaded Data'); });
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Bad async test (no await) | Uncertain DOM state | Potential multiple reflows due to premature assertions | Unstable paint timing | [X] Bad |
| Good async test (await + nextTick) | Controlled DOM updates after async completion | Single reflow after data update | Stable paint after data load | [OK] Good |