💼 This rule is enabled in the 🔥 ember
config.
💡 This rule is manually fixable by editor suggestions.
Ember's old built-in find('.selector')
acceptance test helper function always returns an array, even when no elements match. As a result, assert.ok(find('.selector'))
will always pass, even if no elements are found, as an empty array is still truthy.
Note: find from @ember/test-helpers
does not have this problem.
This rule disallows the aforementioned test assertion.
Examples of incorrect code for this rule:
test('the element exists', function (assert) {
assert.ok(find('.selector'));
});
Examples of correct code for this rule:
test('the element exists', function (assert) {
assert.equal(find('.selector').length, 1);
});
test('the element exists', function (assert) {
assert.dom('.selector').exists(); // qunit-dom
});
import { find } from '@ember/test-helpers';
test('the element exists', function (assert) {
assert.ok(find('.selector'));
});
- See the documentation for Ember's
find
acceptance test helper - See the documentation for the
qunit-dom
package - Related rule: qunit-dom/no-ok-find