# Mocking External HTTP Requests in Node Tests with Nock

Testing code that depends on external services and APIs, e.g. the [GitHub API][1], has a variety of challenges. Writing tests that make real HTTP requests to these services may be error-prone due to issues such as network connectivity, API changes, rate limiting and so on. [Nock][2] allows us to avoid these challenges by intercepting external HTTP requests and enabling us to return custom responses, making unit testing easier.

By the end of this article, you will:

- Learn how to run unit tests against a real HTTP endpoint
- Learn how to return different responses to different HTTP endpoints, and
- Know how to record and playback live HTTP requests to make testing easier.

Read the rest of the article [on the Semaphore Blog][3].

[1]: https://developer.github.com/v3/
[2]: https://github.com/nock/nock
[3]: https://semaphoreci.com/community/tutorials/mocking-external-http-requests-in-node-tests-with-nock
