14 Testing asynchronous components
This chapter covers
- Testing synchronous components
- Testing components with asynchronous behavior
- Implementing the
nextTick()
function
Testing components whose behavior is purely synchronous is straightforward. But components can have asynchronous hooks or event handlers, so testing them becomes a bit more complicated (and interesting) in these cases.
The main question the tester must face is how you know when all the asynchronous jobs have finished executing and the component has re-rendered. In this chapter, you’ll implement a nextTick()
function. This function returns a Promise
that resolves when all the pending jobs in the scheduler have finished executing. This way, by await
ing this Promise
, you ...
Get Build a Frontend Web Framework (From Scratch) now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.