Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration test method to "destroy" the component #217

Closed
olivierlesnicki opened this issue Feb 22, 2016 · 5 comments
Closed

Integration test method to "destroy" the component #217

olivierlesnicki opened this issue Feb 22, 2016 · 5 comments

Comments

@olivierlesnicki
Copy link

Is there a way to destroy the tested component in integration tests?

I had the issue where async behavior were setting internal properties on the component on completion. The problem is sometimes the component was destroyed before the async behavior had completed, resulting in an error.

While I fixed the code to handle this situation I would have liked to implement a corresponding test. And maybe use something such as this.destroy() to check the race condition.

@olivierlesnicki
Copy link
Author

I was able to emulate the behavior by passing an attribute named isDestroyed to the component and setting it to true... :)

@rwjblue
Copy link
Member

rwjblue commented Feb 22, 2016

In more recent ember-qunit versions, you can do:

this.clearRender()

@olivierlesnicki
Copy link
Author

@rwjblue thanks

@jakeleboeuf
Copy link

@rwjblue how do I implement this?

test('it renders as canvas', function(assert) {
  this.render(hbs`{{body-movin path="loading" renderType="canvas"}}`);

  return wait().then(() => {
    assert.notEqual(this.$('canvas').get(0), undefined);
    this.clearRender(); // where should this go?
  });
});

@vinceg2012
Copy link

@jakeleboeuf you probably found the solution, but try importing clearRender
Note: Depending on your ember version, your import may be different.

Import:
import { render, clearRender } from '@ember/test-helpers';

Then call directly:
clearRender();

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

No branches or pull requests

4 participants