concept App in category javascript

appears as: App
Testing JavaScript Applications

This is an excerpt from Manning's book Testing JavaScript Applications.

Listing 6.11. index.html
<!DOCTYPE html>
<html lang="en">
  <!-- ... -->
  <body>
    <!-- ... -->
    <script src="bundle.js"></script>  #1
  </body>
</html>

Start by updating updateItemList so that it stores the object passed to it under the inventory key in localStorage. Because localStorage can’t store objects, you’ll need to serialize inventory with JSON.stringify before persisting the data.

Listing 6.48. domController.js
// ...

const updateItemList = inventory => {
  if (!inventory === null) return;

  localStorage.setItem("inventory", JSON.stringify(inventory));  #1

  // ...
}
Figure 8.2. The coverage of a test which renders App, interacts with its child form, and verifies the item list’s elements.
08 02