concept business in category javascript
appears as: business, business, Businesses

This is an excerpt from Manning's book Testing JavaScript Applications.
Automated tests always follow the exact same series of steps. They don’t forget nor make mistakes. They ensure that test cases are followed thoroughly and make it easier to reproduce bugs.
When tests are automated, rework and communication overhead decrease. On their own, developers can immediately verify other people’s work and ensure they haven’t broken other parts of the application.
Listing 2.23. badly_written.test.js
const { app, resetState } = require("./server"); const fetch = require("isomorphic-fetch"); test("adding items to a cart", done => { resetState(); return fetch(`http://localhost:3000/carts/lucas/items`, { method: "GET" }) .then(initialItemsResponse => { expect(initialItemsResponse.status).toEqual(404); return fetch(`http://localhost:3000/carts/lucas/items/cheesecake`, { method: "POST" }).then(response => response.json()); }) .then(addItemResponse => { expect(addItemResponse).toEqual(["cheesecake"]); return fetch(`http://localhost:3000/carts/lucas/items`, { method: "GET" }).then(response => response.json()); }) .then(finalItemsResponse => { expect(finalItemsResponse).toEqual(["cheesecake"]); }) .then(() => { app.close(); done(); }); });