Enforce using assert.equal(...callCount, ...);
instead of assert.ok(...calledOnce);
(square/use-call-count-test-assert
)
💼 This rule is enabled in the following configs: 🔥 ember
, 🔒 strict
.
🔧 This rule is automatically fixable by the --fix
CLI option.
Using callCount
rather than the other shortcut count helpers (such as calledOnce
, notCalled
) allows the test runner to show the actual number of times the spy was called.
This lint rule prevents the use of:
notCalled
calledOnce
calledTwice
calledThrice
called
The above do not provide as much information to the test runner.
Examples of incorrect code for this rule:
test('it works', function (assert) {
assert.ok(this.spy.calledOnce);
});
Examples of correct code for this rule:
test('it works', function (assert) {
assert.equal(this.spy.callCount, 1);
});
- See the documentation for spies and their properties