concept ItemList in category javascript

appears as: ItemList, ItemList
Testing JavaScript Applications

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

Additionally, you must call jest.resetModules before requiring main.js. Otherwise, Jest will get ./main.js from its cache, preventing it from being executed again.

Listing 6.38. main.test.js
const fs = require("fs");
const initialHtml = fs.readFileSync("./index.html");

beforeEach(() => {
  document.body.innerHTML = initialHtml;

  jest.resetModules();  #1
  require("./main");  #2
});
Figure 8.3. The tests which break if you decide to change the format of the text rendered by ItemList.
08 03