chai-immutable 插件
-
从 npm chai,chai-immutable 和 ts-node 安装
npm install --save-dev chai chai-immutable ts-node
-
安装 mocha 和 chai 的类型
npm install --save-dev @types/mocha @types/chai
-
写简单的测试文件:
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); }) })
-
在控制台中运行它:
mocha --compilers ts:ts-node/register,tsx:ts-node/register 'test/**/*.spec.@(ts|tsx)'