emberjs / emberjs/ember-test-helpers

`teardownContext` causing tests to hang

Open
#528 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
188
Forks
254
PR merge metrics
No merged PRs in 30d

Description

`teardownContext` is causing my tests to hang. I have an AJAX request that I expected to hit an endpoint but due to a programmer error in my test, I forgot to `await` the method that would hit the endpoint. This mean't the test ran to completion immediately and but the teardown would hang. After further investigation, I found the teardown could *never* complete because we remove the mechanism for updating the settled state values for pending requests.

https://github.com/emberjs/ember-test-helpers/blob/4ad756ee62ee6c87b1a9ec0e27a66bc5c3b092e7/addon-test-support/%40ember/test-helpers/teardown-context.ts#L36-L45

We call `_teardownAJAXHooks` which removes the listeners that will mutate `pendingRequests` and then we call `settled` which waits on the value of `pendingRequests` to change to zero. As a consequence of this, the tests hang until timeout.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.