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 awaiting this Promise, you can be sure that the component has re-rendered, and you can check what’s in the Document Object Model (DOM).

14.1 Testing components with asynchronous behavior: nextTick()

 

14.1.1 Testing a component with an asynchronous onMounted() hook

 
 
 
 

14.1.2 The fundamentals behind the nextTick() function

 
 
 

14.1.3 Implementing the nextTick() function

 
 
 

14.2 Publishing version 4.1 of the framework

 
 

14.3 Where to go from here

 
 
 

Summary

 
 
 
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage