Skip to main content

Mocha

Basic Setup

Solution

const add = (a, b) => a + b;
const add = (a, b) => a + b;

Tests

const {assert, config, expect} = require("chai");

// don't truncate assertion diff output
config.truncateThreshold = 0;

describe("add", () => {
  it("should add two numbers", () => {
    assert.strictEqual(add(1, 2), 3);

    // ...or use expect assertions:
    expect(add(1, 2)).to.equal(3);
  });
});
const {assert, config, expect} = require("chai");

// don't truncate assertion diff output
config.truncateThreshold = 0;

describe("add", () => {
  it("should add two numbers", () => {
    assert.strictEqual(add(1, 2), 3);

    // ...or use expect assertions:
    expect(add(1, 2)).to.equal(3);
  });
});