Writing BDD-style tests with Mocha

From C# or Java, you may be most familiar with the xUnit-style of tests used by NUnit, JUnit, and so on. This style structures tests into classes, and turns method names into test names. This can be a bit restrictive, and isn't common in JavaScript testing. JavaScript test frameworks make use of the less structured, and more dynamic, nature of the language to allow more flexibility.

There are several different styles for writing tests in JavaScript. The most common is the so-called behavior-driven development (BDD) style in which we describe the behavior of our application in plain English. This is the default style of the most popular JavaScript testing frameworks. It is also common in frameworks for other programming ...

Get Learning Node.js for .NET Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.