ember-test-helpers' Click() is not waiting for MakeRequest
tpetrone opened this issue · 9 comments
We are facing a timing issue during an acceptance test that performs a login. Sometimes it works, sometimes it does not.
In our code, clicking a button triggers an action that calls authenticate()
method and upon resolution, the user gets transitioned to an authenticated route - a pretty common login flow. The application is configured to use jwt authenticator.
During the test execution, sometimes it reaches settled
ness before actually resolving the promise. In other words, before authenticate.then
. Further investigations led me to understand that there is a potencial problem at makeRequest
method (token.js).
The tests do always wait for the completion of fetch
but it doesn't necessarily wait for response.text()
promise.
Is this an expected behaviour?
It may be related to emberjs/ember-test-helpers#339
Definitely related to ember-cli/ember-fetch#204
@tpetrone Thanks for reporting this! I'm slammed at work right now so it may be a day or two before I can dig in. It looks like you are working on it. Right now, does this appear to be an issue we need to resolve in the library? Thanks.
Hi @fenichelar!
AFAIK using the option below is a valid workaround.
'ember-fetch': {
preferNative: true
}
@tpetrone Is this something we should add to the package.json
of this library or add a note in the documentation about adding to the project using this libraries package.json
?
@fenichelar I think it would be enough to mention in the docs. I forgot to mention but this is a build option. That piece of code should go in ember-cli-build.js
of the client app.
Okay, I'll add it to the testing section of the readme: https://github.com/jpadilla/ember-simple-auth-token#testing-configuration.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.