I am trying to test a node.js webapp I have started working on with Mocha and Zombie. But there are a few things I still don't understand and would like some help. Please note that I am using express
Suppose I am testing the user authentication. Obviously there are two parts: 1 - the user interface 2 - the behavior, involving the controllers and the models So, I've decided to separate both parts. For the UI, I have decided to use zombie. The following link contains the UI tests I've written for the user authentication: https://gist.github.com/7e45d6884ce2d32e933d Basically, my user authentication form contains a username and password input fields and a Sign In button. I am interested in four scenarios: when at least one of the input field is empty and when both have been provided by the user. Although the four tests pass right now, I am still not convinced they are the right tests, or whether it's enough or does the right thing. What do you guys (BDD experts) think? thanks José
Since your tests seem to be asynchronous, you should be calling the
done
function given to the callback of theit
functionYou might also want to check for the error message your app prints when there is an error authenticating.
Besides checking all the fields are given, you should also test a valid authentication, a wrong password, and existing username if your app provides that error message. And if you went as far as only allowing a number of attempted logins every few minutes, test for that too.