TDD versus BDD with Mocha and Chai

As we have already seen, TDD and BDD follow many of the same principles, but have some differences in their style. While these two styles provide the same functionality, BDD is considered to be easier to read by many developers.

The following table compares the naming and style of the suites, tests, and assertions used by the TDD and BBD styles:

TDD

BDD

suite

describe

setup

before

teardown

after

suiteSetup

beforeEach

suiteTeardown

afterEach

test

it

assert.equal(math.PI, 3.14159265359);

expect(math.PI).to.equals(3.14159265359);

Get Learning TypeScript 2.x - Second Edition 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.