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

1.13.4 breaks some component unit tests #11738

Closed
thec0keman opened this issue Jul 14, 2015 · 13 comments
Closed

1.13.4 breaks some component unit tests #11738

thec0keman opened this issue Jul 14, 2015 · 13 comments

Comments

@thec0keman
Copy link

In moving from 1.13.3 -> 1.13.4, some of our unit tests are breaking.

It is a bit hard to nail down exactly because it happens in random places, but the context for the test itself has subject set to nil:

test('it renders', function(assert) {
  var subject = this.subject();
});

=>

TypeError: this.subject is not a function
    at Object.<anonymous> (http://localhost:7357/assets/app.js:72630:26)
    at Object.wrapper (http://localhost:7357/assets/test-support.js:1821:29)
    at Object.Test.run (http://localhost:7357/assets/test-support.js:3502:28)
    at http://localhost:7357/assets/test-support.js:3631:11
    at process (http://localhost:7357/assets/test-support.js:3190:24)
    at begin (http://localhost:7357/assets/test-support.js:3235:2)
    at http://localhost:7357/assets/test-support.js:3251:4

Dropping in a debugger, and the test context is clearly different:
image

@stefanpenner
Copy link
Member

Can you provide a repo that demonstrates this. That will make it more actionable

@twokul
Copy link
Member

twokul commented Jul 14, 2015

@thec0keman which version of qunit are you on? in the newest version you need to specify integration: true in order to use this.subject()

@stefanpenner
Copy link
Member

@twokul i suspect that is the issue.

@thec0keman
Copy link
Author

Running 0.4.1. We are using the needs array which should be flagging them as integration, which works for most of the tests most of the time, and all of the tests in 1.13.3.

@stefanpenner I'll work on extracting some of the failing tests into a repo. Thx.

@stefanpenner
Copy link
Member

@thec0keman i believe your bug isn't with ember (this repo), and rather with the https://github.com/switchfly/ember-test-helpers

@mixonic
Copy link
Sponsor Member

mixonic commented Jul 14, 2015

@thec0keman the default test helper behavior changed from unit to integration a patch release of ember-test-helpers. I agree with @stefanpenner you may be hitting that.

Please confirm you bumped test-helpers as well to cause this. You can flag all your old component test modules unit: true to restore the old behavior.

@thec0keman
Copy link
Author

Thanks for the suggestions. After digging deeper, the problem was being obscured by something in our app munching RSVP errors for tests. this.subject being null was a symptom of the prior test not tearing down correctly, so the app root element was trying to be reused.

The real problem is a template like the following:

{{#if savedOption}}
  <button {{action "removeOption" on="click"}}></button>
{{else}}
  {{input value=inputValue}}
{{/if}}

where removeOption simply nullifies savedOption. There is some weird interplay between removing the button element and adding the input that raises:

Uncaught Error: Assertion Failed: BUG: Render node exists without concomitant env.

I can post a repo demonstrating this if desired.

@stefanpenner
Copy link
Member

This appears to be an issue with the test helpers. They should not end up in a bad state like this. Can you open the issue on that repo?

@thec0keman
Copy link
Author

Absolutely. Wouldn't the BUG: Render node exists without concomitant env. be Ember related though?

@rwjblue
Copy link
Member

rwjblue commented Jul 14, 2015

A recent update to test helpers should properly handle errors in setup (and not fail like this).

@rwjblue
Copy link
Member

rwjblue commented Jul 14, 2015

@thec0keman - Yes, I would say that would still be an ember issue (though not really related to this issues title or description), can you make a demo JSBin that reproduces?

@thec0keman
Copy link
Author

I cannot reproduce this in JSBin. It only seems to be happening with testing, so I'll move the issue to ember-test-helpers (here).

@egemon
Copy link

egemon commented Jan 21, 2017

If somebody will every look at the similar issue, I had had one, because my willDestroyElement() hook had threw exception, so element was not destroyed.

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

No branches or pull requests

6 participants