Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Using run.join not working with thrown error #449

Open
bobisjan opened this issue Aug 7, 2019 · 0 comments
Open

Using run.join not working with thrown error #449

bobisjan opened this issue Aug 7, 2019 · 0 comments

Comments

@bobisjan
Copy link

bobisjan commented Aug 7, 2019

Hi,

I've encounter a never ending test with failed AJAX. When error is thrown (eq. not handled in the task), then run.join throws this error immediately and fails to continue with always() part, so the test never settles.

export default class extend Component {
  @service ajax;

  @task(function *() {
    yield this.ajax.request('/api/data');
  }) load;
}
<button {{on "click" (perform this.load)}}>
  load
</button>

{{#if this.load.last.error}}
  <span class="error">error</span>
{{/if}}
test('it displays error', async function(assert) {
  assert.expect(2);

  this.server.get('/api/data', () => new Mirage.Response(500));

  setupOnerror(error => {
    assert.ok(error);
  });

  await this.render(hbs`<Loader />`);

  await click('button');

  assert.equal(this.element.querySelector('.error').textContent, 'error');
});

I've switched from run.join to run.next locally and then test continues as I would expect, but I'm not sure if this is a good fix for this, because I'm not familiar with runloop 😔.

Thanks for any advice.

/cc @rwjblue

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant