Flashcards in Integration testing with Mocha and Chai Deck (7)
Describe the difference between unit and integration tests.
A unit test validates whether a unit of code performs and executes in the way it was intended.
An integration test validates if a group of units ( or modules or components ) work together as they were intended.
Write integration tests in Node using Mocha and Chai
Write asynchronous tests in Node using Mocha and Chai.
Asynchronous tests are easy to write using Mocha. Checking out the mochajs.org site we cover this. Within mocha you have the describe( ) method. The describe method takes two arguments and uses this as its testing base. The describe( ) method takes the name of the function being tested and the function that does the testing.
Test an HTTP API in Node using Mocha and Chai.
Test SQL database queries in Node using Mocha and Chai.
Describe what Mocha's done function is for in Node. Also explain what the it( ) does.
The done( ) function can be used in the stead of a Promise function.
The it( ) function is used in mocha async tests to further describe what the function being tested is doing. The it( ) takes two arguments the description of what it does and the function that checks to see if it performs as described.
On the mochajs.org landing page we're introduced to how easy asynchronous coding is, we're also introduced to a function frequently used in async coding the done callback function (function taken as an arg and called inside the function) to the it( ) method. The done function