TypeScript chai-immutable plugin


Example

  1. Install from npm chai, chai-immutable, and ts-node

    npm install --save-dev chai chai-immutable ts-node
    
  1. Install types for mocha and chai

    npm install --save-dev @types/mocha @types/chai
    
  2. Write simple test file:

      import {List, Set} from 'immutable';
      import * as chai from 'chai';
      import * as chaiImmutable from 'chai-immutable';
    
      chai.use(chaiImmutable);
    
      describe('chai immutable example', () => {
        it('example', () => {
          expect(Set.of(1,2,3)).to.not.be.empty;
    
          expect(Set.of(1,2,3)).to.include(2);
          expect(Set.of(1,2,3)).to.include(5);
        })
      })
    
  3. Run it in the console:

    mocha --compilers ts:ts-node/register,tsx:ts-node/register 'test/**/*.spec.@(ts|tsx)'