diff --git a/README.md b/README.md index 43aaab49..eb124408 100644 --- a/README.md +++ b/README.md @@ -543,7 +543,7 @@ All statements above will return false if used with `===` **Otherwise:** A bug in Express middleware === a bug in all or most requests -🔗 [**Read More: Choosing CI platform**](/sections/testingandquality/test-middlewares.md) +🔗 [**Read More: Test middlewares in isolation**](/sections/testingandquality/test-middlewares.md)


diff --git a/sections/testingandquality/test-middlewares.md b/sections/testingandquality/test-middlewares.md index a6a850a4..eb1331e4 100644 --- a/sections/testingandquality/test-middlewares.md +++ b/sections/testingandquality/test-middlewares.md @@ -8,23 +8,23 @@ Many avoid Middleware testing because they represent a small portion of the syst

-### Code example: Testing middleware in isolation without issuing network calls and waking-up the entire web framework +### Code example: Testing middleware in isolation ```javascript //the middleware we want to test -const unitUnderTest = require('./middleware') -const httpMocks = require('node-mocks-http'); +const unitUnderTest = require("./middleware"); +const httpMocks = require("node-mocks-http"); //Jest syntax, equivelant to describe() & it() in Mocha -test('A request without authentication header, should return http status 403', () => { +test("A request without authentication header, should return http status 403", () => { const request = httpMocks.createRequest({ - method: 'GET', - url: '/user/42', + method: "GET", + url: "/user/42", headers: { - authentication: '' + authentication: "" } }); const response = httpMocks.createResponse(); unitUnderTest(request, response); expect(response.statusCode).toBe(403); }); -``` \ No newline at end of file +```