-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
Clear and concise description of the problem
Following this discussion, I think it would be good to provide Chai-like assertions for all Jest-like assertions.
Especially in the case of spies/mocks, the assertions could be similar to sinon-chai or consistent with the existing Jest assertions.
For examples:
toHaveBeenCalled()->to.have.been.calledorto.have.been.called()toHaveBeenCalledTimes(n)->to.have.callCount(n)orto.have.been.calledTimes(n)toHaveBeenCalledWith(args)->to.have.been.calledWith(args)- ...
Suggested solution
Assuming the new assertions should be consistent with the existing ones, the changes could be just adding new assertion names in jest-expect.ts. For example:
def(['toHaveBeenCalled', 'toBeCalled', 'called'], function () { ...}However, the file might have to be renamed to something like jest-chai-expect.ts, because it's not only about Jest anymore.
Alternative
If we don't want to mix the the Jest and Chai assertions in the same file, another solution could be moving the assertion functions to a new shared module, then defining the Jest assertions in jest-expect.ts and the Chai assertions in chai-expect.ts.
Additional context
I'd be glad to create a PR, once this feature request is accepted and an implementation is recommended.
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that request the same feature to avoid creating a duplicate.