ABSTRACT

JavaScript uses the same pattern for unit testing as most other modern languages. Each test is written as a function, and each of those functions tests one particular aspect of the code. A standalone program called a test runner finds test functions, runs them, and reports the results. Any setup code that needs to be run before each test to create the data for the test’s input (called its fixture) is put in a function of its own. It’s increasingly common for servers to return data that is rendered by the client rather than generating and returning HTML, but some servers still do the latter. Do not try to check this with substrings or regular expressions: the exceptions have exceptions, and that way lays madness. Suppose a JavaScript program contains some JSX expressions that produce HTML which is then read and displayed by a browser.