Thanks to visit codestin.com
Credit goes to github.com

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

Using run.join not working with thrown error #449

@bobisjan

Description

@bobisjan

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions