Example project to allow me to show how best to unit test a JavaScript Express application.
Clone this repository and install the dependencies as follows:
git clone [email protected]:MarcL/js-unit-testing-framework.git
npm install
The code sets up a basic Express server with a few routes and some tests which cover testing the server setup. Run the test suite using npm:
npm test
Take a look in the test
directory to see all of the test code. There are lots of examples of different types of tests and how to create them.
Some examples of how to test asynchronous functions and promises, including some tips and tricks and gotchas.
done
callback isn't called when function succeedsdone
callback isn't called when function throws an errordone
callback when function throws an errordone
callback is called after resolutiondone
callback is called after resolution using chai-as-promised
syntaxdone
callback is calleddone
callback is called using chai-as-promised
syntaxSee LICENSE