✅ The "extends": "plugin:ember/recommended"
property in a configuration file enables this rule.
🔧 The --fix
option on the command line can automatically fix some of the problems reported by this rule.
Most of the test helper functions in
@ember/test-helpers
call
settled()
internally, which causes the test to wait until any effects of e.g.
the click()
operation have settled. This means calling await settled()
after
calling one of these test helpers is redundant and should not be necessary.
In some cases this pattern is mistakenly used to "wait a little more", which usually indicated a deeper root cause issue, like a race condition or missing test waiter somewhere. This pattern only works sometimes because it causes the test to continue on the next tick of the JS runloop, instead of continuing directly. It is highly recommended to fix the root cause in these cases instead of relying on such brittle workarounds.
This rule warns about cases where await settled()
is used right after a call
to a test helper function that already calls settled()
internally (or
settled()
itself).
Examples of incorrect code for this rule:
test('...', async function (assert) {
await click('.foo');
await settled();
});
test('...', async function (assert) {
await fillIn('.foo');
await settled();
});
test('...', async function (assert) {
await settled();
await settled();
});
Examples of correct code for this rule:
test('...', async function (assert) {
await waitFor('.foo');
await settled();
});
- Have a look at the ember-test-waiters project