Integration Testing
Last updated
Last updated
To view lecture notes for this course, please consult the .
Introducing dependencies on external modules or data also turns unit tests into integration tests.
If one module misbehaves in a chain of interrelated modules, it is not so immediately clear where to look for the cause of the failure. When code under development relies on a database, a web service, or any other external process or service, enforcing a unit-testable separation is also an opportunity and a driving force to design more modular, more testable and more reusable code.
Open 2 terminal prompts
run the command couchdb
cd integration-tests
II. Using text editor of your choice open program.test.js and complete each TODO block.
Paste this GET request into terminal that is expecting request and line feed and hit enter twice
Whichever way you use choose you get the following JSON payload
Add assertion to expect function call in line 16 using the payload information.
1. Use appropriate supertest method to remove document. 2. Make assertion with the returned status code (204) is usual status for DELETE request.
The Super Test library api docs can be found here
1. Use post method in supertest 2. Use set method in supertest and pass in object with Accept and Content-Type headers. 3. Use send method in supertest and pass in object with a name and document property. 4. Make sure to call expect in supertest to do assertion and use previous get request as example. 5. Make sure to end supertest call with end function call or the integration test won't finish. 6. Check statuscode with SuperTest property 7. Use assertion methods from Tape 8. CouchDB api documentation 9. CouchDB driver for node.js (nano) that I am using
The Super Test library api docs and rest methods can be found here