Skip to Content
Build a Frontend Web Framework (From Scratch)
book

Build a Frontend Web Framework (From Scratch)

by Angel Sola
May 2024
Beginner to intermediate
384 pages
9h 29m
English
Manning Publications
Content preview from Build a Frontend Web Framework (From Scratch)

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 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

React - The Complete Guide (Includes Hooks, React Router, and Redux) - Second Edition

React - The Complete Guide (Includes Hooks, React Router, and Redux) - Second Edition

Academind by Maximilian Schwarzmüller GmbH
Full Stack Testing

Full Stack Testing

Gayathri Mohan

Publisher Resources

ISBN: 9781633438064Supplemental ContentPublisher SupportOtherPublisher WebsiteSupplemental ContentPurchase Link