DOM 操作

    displayUser.js

    __tests__/displayUser-test.js

    Also, the function being tested adds an event listener on the DOM element, so we need to set up our DOM correctly for the test. jsdom and the package simulate a DOM environment as if you were in the browser. This means that every DOM API that we call can be observed in the same way it would be observed in a browser!

    The code for this example is available at examples/jquery.