Choosing a test style that fits
Mocha and Chai both provide different library interfaces for writing tests. This conveniently allows developers to choose an appropriate test paradigm or style for different projects while still leveraging the same underlying functionality.
Mocha test interfaces
Mocha currently offers four interfaces for test suites and specifications:
The Behavior-Driven Development (BDD) interface: This interface uses test constructs similar to those popularized by the Ruby RSpec framework (http://rspec.info/).
The Test-Driven Development (TDD) interface: This interface uses more traditional unit test keywords such as
suite
andtest
.The exports interface: This interface utilizes a modular format familiar to Node.js/CommonJS developers, implementing the test functionality as properties of a
module.exports
object.The QUnit-styled interface: This interface uses a flat declaration paradigm taken from the popular QUnit test framework (http://qunitjs.com/). A suite in this style...