Skip to content

Mocha

Medium — good to knowTesting

ELI5 — The Vibe Check

Mocha is an older, flexible JavaScript test runner that lets you pick your own assertion library and mocking tools. It's like a buffet — Mocha provides the plates, and you bring your own food (Chai for assertions, Sinon for mocks). More setup, more control.

Real Talk

Mocha is a flexible JavaScript test framework for Node.js that provides describe/it blocks and lifecycle hooks (before, after, beforeEach, afterEach). Unlike Jest, it doesn't include assertions or mocking — you combine it with Chai and Sinon.

Show Me The Code

const { expect } = require('chai');

describe('Calculator', () => {
  it('should add two numbers', () => {
    expect(add(2, 3)).to.equal(5);
  });
});

When You'll Hear This

"This project uses Mocha + Chai — don't use Jest matchers here." / "Mocha is more flexible but Jest is simpler to set up."

Made with passive-aggressive love by manoga.digital. Powered by Claude.