Get started with chai CDN

MIT licensed

Chai is a flexible, modular JS assertion library for testing various kinds of code.

Tags:
  • test
  • assertion
  • assert
  • testing
  • chai

Stable version

Copied!

How to start using chai CDN


// Include Chai library from the CDN
const chai = require('chai');
const assert = chai.assert;

// Your test suite
describe('Simple Test Suite', () => {
  it('should check if 1 is equal to 1', () => {
    const num1 = 1;
    const num2 = 1;

    // Use Chai assertions
    assert.strictEqual(num1, num2);
  });

  it('should check if a string is empty', () => {
    const str = '';

    // Use Chai assertions
    assert.isEmpty(str);
  });

  it('should check if an array is empty', () => {
    const arr = [];

    // Use Chai assertions
    assert.isEmpty(arr);
  });

  it('should check if a number is a multiple of another number', () => {
    const num1 = 6;
    const num2 = 3;

    // Use Chai assertions
    assert.isMultiple(num1, num2);
  });
});
Copied!

All versions