Open weijie-tang opened 7 years ago
The second assertion worked after using chai.should(); in my imports, but the first one still has the same issue.
The expect
assertion works well for me with chai-as-promised & chai-things.
Import:
import chaiThings from 'chai-things';
import chaiAsPromised from 'chai-as-promised';
chai.use(chaiThings);
chai.use(chaiAsPromised);
Assert:
return expect(request)
.to.eventually.be.an('array')
.that.contains.something.with.property('x', 'y');
Maybe I'm missing something here, but I'm still getting this error:
TS2339: Property 'have' does not exist on type 'PromisedKeyFilter'.
I'm running these versions
"@types/chai": "^4.2.4",
"@types/chai-as-promised": "^7.1.2",
"@types/chai-things": "^0.0.34",
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"chai-things": "^0.2.0",
"typescript": "^3.6.3",
Here's the repro
import chai from 'chai';
import chaiThings from 'chai-things';
import chaiAsPromised from 'chai-as-promised';
import 'mocha';
const should = chai.should();
chai.use(chaiThings);
chai.use(chaiAsPromised);
const { expect } = chai;
async function foo(): Promise<any> {
return [ { bar: 'baz' }, { bar: 'baz' } ];
}
describe('foo', () => {
it('works', async () => {
foo().should.eventually.all.have.property('bar', 'baz');
await expect(foo()).to.eventually.all.have.property('bar', 'baz');
})
})
Any ideas?
When parsing the values of an array returned by a promise, I get weird behavior.
Given the following versions of chai, chai-things, chai-as-promised and typescript:
And the following import order:
And the following assertions:
I get the following error: