Can someone explain to me, why the following code won’t wait for asynchronous click function?
import { module, test } from 'qunit';
import { click, visit, currentURL, fillIn, pauseTest } from '@ember/test-helpers';
import { setupApplicationTest } from 'ember-qunit';
module('Acceptance | login', async function(hooks) {
setupApplicationTest(hooks);
test('should login', async function(assert) {
await visit('/login');
await fillIn('input#email', 'martin.barilik@noh2o.com');
await fillIn('input#password', '123456');
await click('button[type="submit"]');
// await pauseTest();
assert.equal(this.element.querySelector('div.list-group a').textContent, 'Dashboard');
});
});
The button is calling async authenticate function:
@action
async authenticate(e) {
e.preventDefault();
let { email, password } = this;
try {
await this.session.authenticate('authenticator:custom', email, password);
} catch(error) {
this.errorMessage = error.error || error;
}
}
If i uncomment await pauseTest(), i can see the page being loaded and after resumeTest() i get successful assertion, but without it it fails with error:
Source: TypeError: Cannot read property 'textContent' of null
Which indicates, that the await is not waiting and assert.equal is executed before the page is loaded.
edit: i am using remote adapter as a backend (sailsjs server)
What am i doing wrong?