I'm trying to use chai-as-promised
package with TypeScript. First of all, the following code works well in simple JavaScript.
import * as chai from 'chai';
import * as chaiAsPromised from 'chai-as-promised';
chai.use(chaiAsPromised);
const expect = chai.expect;
import * as sinon from 'sinon';
import { MyClass } from '.';
describe('Test my class', () => {
let myClass: MyClass;
beforeEach(() => {
myClass = new MyClass();
});
it('Should render home', () => {
const req = new RequestMock();
const res = new ResponseMock();
return expect(myClass.getHomePage(req, res)).to.be.fulfilled()
.then((returnedValue) => {
chai.expect(returnedValue).to.not.be.equal([]);
});
});
});
I have the following error with this code :
... and it pointed to this :
interface PromisedTypeComparison {
(type: string, message?: string): PromisedAssertion; // <<--
instanceof: PromisedInstanceOf;
instanceOf: PromisedInstanceOf;
}
I tested plenty of opportunity and it is the one where I am closest to the solution it seems to me.
I would like to use function of chai-as-promise
like fullfulled
, rejected
... etc.
How can i make it ?
Just import the default of
chai-as-promised
and everything will work: