JavaScript Testing

Noun

Feature: Serve coffee
Coffee should not be served until paid for
Coffee should not be served until the button has been pressed
If there is no coffee left then money should be refunded

test framework

Jasmine

Mocha: beforeEach, describe, context, it

assertion library

Chai: expect, equal, and exist

power-assert "No API is the best API"

End to End Testing

end to end testing framework: Protractor (run against real browser)

Which method comes from Mocha and Chai

We can distinguish between framework (Mocha) methods and assertion library (Chai) methods by looking at the contents of the it block. Methods outside the it block are generally derived from the testing framework. Everything within the it block is code coming from the assertion library. beforeEach, describe, context, it, are all methods extending from Mocha. expect, equal, and exist, are all methods extending from Chai.