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

Singletons are not destroyed between integration tests #222

Closed
olivierlesnicki opened this issue Apr 25, 2016 · 9 comments
Closed

Singletons are not destroyed between integration tests #222

olivierlesnicki opened this issue Apr 25, 2016 · 9 comments

Comments

@olivierlesnicki
Copy link

It seems services are shared between all the component integration tests instead of being destroyed after each test.

@rwjblue
Copy link
Member

rwjblue commented Apr 25, 2016

In general, this is not true. Can you provide a reproduction?

@olivierlesnicki
Copy link
Author

Ok...

@rwjblue
Copy link
Member

rwjblue commented Apr 26, 2016

Here is a demo for you to tweak: http://rwjblue.jsbin.com/doqupuc/edit?html,js,output

@olivierlesnicki
Copy link
Author

@rwjblue thanks for this, I actually have a repository replication the issue ready https://github.com/olivierlesnicki/ember-quunit-issue-222

I've actually been tripped up by Prototype inheritance - my issue might have nothing to do with ember-qunit (see how I declared the array "elements" against "shared-service" factory).

@olivierlesnicki
Copy link
Author

However while playing around with this issue I've discovered something a bit odd that I cannot explain: right now if you run my app you see two assertions failing for b-component (as expected). However if you comment out one of the render/assertion pair - no test are failing anymore:

// 2 assertions failling
test('it renders', function(assert) {
  // Set any properties with this.set('myProperty', 'value');
  // Handle any actions with this.on('myAction', function(val) { ... });

  this.render(hbs`{{b-component}}`);

  assert.equal(this.$().text().trim(), '');

  // // Template block usage:
  this.render(hbs`
    {{#b-component}}
      template block text
    {{/b-component}}
  `);

  assert.equal(this.$().text().trim(), 'template block text');
});
// none is failling
test('it renders', function(assert) {
  // Set any properties with this.set('myProperty', 'value');
  // Handle any actions with this.on('myAction', function(val) { ... });

  this.render(hbs`{{b-component}}`);

  assert.equal(this.$().text().trim(), '');
});

@rwjblue
Copy link
Member

rwjblue commented Apr 26, 2016

Yes, olivierlesnicki/ember-quunit-issue-222@f95e239#diff-e71cd78cefaba8e1397165631a08bb18R4 is incorrect, setting that array there shares with all instances of a service.

@olivierlesnicki
Copy link
Author

olivierlesnicki commented Apr 26, 2016

Thanks for spending time on this one. One quick question (which I've sort of alluded in my previous comment) but any idea why this test is flacky?

http://jsbin.com/cuvehapoja/1/edit?html,js,output

(In Chrome, refreshing the page between each test run yields different results)

(see video evidence http://fr.tinypic.com/r/2qko7s2/9)

@rwjblue
Copy link
Member

rwjblue commented Apr 26, 2016

By default QUnit runs failed tests first (they use session storage to keep track of the test ids that change). Once component:test-thong fails in one run, it will be ran first in the next run. In that case, since test-thong does not add any items to the service the expected output is correct.

@rwjblue rwjblue closed this as completed Apr 26, 2016
@olivierlesnicki
Copy link
Author

@rwjblue thanks :)

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

2 participants