concept this route in category javascript

appears as: this route
Testing JavaScript Applications

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

  • If the route’s response is correct
  • Figure 4.10. The part of the middleware with which this integration test interacts.
    04 10
    Listing 4.61. server.test.js
    const nock = require("nock");
    
    // Don't forget to remove the mock you've done for `isomorphic-fetch`!
    
    // ...
    
    beforeEach(() => nock.cleanAll());  #1
    
    describe("fetch inventory items", () => {
      // ...
    
      test("can fetch an item from the inventory", async () => {
        const eggsResponse = {
          title: "FakeAPI",
          href: "example.org",
          results: [{ name: "Omelette du Fromage" }]
        };
    
        nock("http://recipepuppy.com")  #2
          .get("/api")
          .query({ i: "eggs" })
          .reply(200, eggsResponse);
    
        const response = await request(app)  #3
          .get(`/inventory/eggs`)
          .expect(200)
          .expect("Content-Type", /json/);
    
        expect(response.body).toEqual({  #4
          ...eggs,
          info: `Data obtained from ${eggsResponse.title} - ${eggsResponse.href}`,
          recipes: eggsResponse.results
        });
      });
    });