I am developing a RESTful Node.js API (express + mongoose) This API calls a third-party Oauth API (google, facebook, whatever).
I am very pleased with the setup of automatic testing with the request mocha + chai + so far, but I had problems mocking a third-party API to check the route (my API) that calls it. I tried using nock but this does not work for my use.
To run my tests, I launch my API ( npm start
), and on another tab I launch a test package ( npm test
). The test case uses a request to test the API through HTTP. Therefore, I think that knocking doesnβt work here, because it mocks http in the "test suite" process, not in the "API" process.
I absolutely need to make fun of this third party for two reasons: 1. I want to be able to run my test suite offline with everything that works on my laptop 2. Since the third-party API uses Oauth, there are strict coding requirements in the test suite (even for test account) do not seem too light.
I would really like not to leave this giant hole in my test coverage, so any advice would be greatly appreciated!
source
share