I'm trying to use chai in typescript and I can't get any of the assertions to work as I would expect.
package.json
"dependencies": {
"@types/chai": "^4.0.1",
"@types/mocha": "^2.2.41",
"chai": "^4.1.0",
"mocha": "^3.4.2",
"typescript": "2.4.2"
}
All of these emit compiler errors:
import * as chai from 'chai';
const expect = chai.expect;
const assert = chai.assert;
const expect = chai.expect;
expect(myVar).to.be.empty();
expect(myVar).to.be.empty;
expect(myVar).to.be.undefined();
expect(myVar).to.be.undefined;
If I try to import assertions directly - I don't see empty() as a valid assertion:
const assert = chai.assert;
assert.empty??? not there?
Any ideas are welcome.
Thanks - Chad
Quick answer
Shaun points out below - change the import to:
import { assert, expect } from 'chai';
Thanks Shaun