Disallow usage of expect() statements when they are alone in a
then()
or should()
.
Some problems reported by this rule are automatically fixable by the
--fix
command line option.
This rule makes code easier to read when both conditions are met:
- a
then()
(orshould()
) contains a single call toexpect()
and - the
then()
(orshould()
) has the same argument asexpect()
.
Example of incorrect code for this rule:
cy.wait("@PutCountry")
.its("request.body.userIds")
.then((userIds) => {
expect(userIds).to.have.members(expectedUserIds);
});
Example of correct code for this rule:
cy.wait("@PutCountry")
.its("request.body.userIds")
.should("have.members", expectedUserIds);
When you don't mind having code that is harder to read than necessary.