We should add async support to the core. This means chai-as-promised will no longer be needed in most cases (but will still be useful if you prefer the style it uses).
This kind of API:
expect(val).resolves.to.equal(303);
expect(val).rejects.to.throw("error");
This is very similar to vitest's existing chai extension. So it is also possible we can remove a lot of code from vitest once this becomes stable in core.
A few notes of things we'd need to do:
- All assertions would need to return a
Promise<void> if the special flag is set
- We can likely do this by wrapping all
addMethod and addChainableMethod in something which conditionally awaits based on the special flag
- The special flag would be something like
flag(this, 'promise') or flag(this, 'isAsync')
- A new
resolves property would need to be added which sets the special flag
- It would also need to set
object to a new promise which, when resolved, sets object again to the resolved value
- A new
rejects property would need to be added which sets the special flag
cc @koddsson @keithamus
We should add async support to the core. This means
chai-as-promisedwill no longer be needed in most cases (but will still be useful if you prefer the style it uses).This kind of API:
This is very similar to vitest's existing chai extension. So it is also possible we can remove a lot of code from vitest once this becomes stable in core.
A few notes of things we'd need to do:
Promise<void>if the special flag is setaddMethodandaddChainableMethodin something which conditionally awaits based on the special flagflag(this, 'promise')orflag(this, 'isAsync')resolvesproperty would need to be added which sets the special flagobjectto a new promise which, when resolved, setsobjectagain to the resolved valuerejectsproperty would need to be added which sets the special flagcc @koddsson @keithamus