Closed BryanCrotaz closed 9 years ago
I suggest we leave this PR open until the underlying hbs renderer or Component.detectinstance
are fixed
@rwjblue is this an Ember bug, or something else?
Using the technique in http://alisdair.mcdiarmid.org/2015/06/20/ember-component-integration-tests.html render a component (possibly with components inside it). Then spin through the DOM and use Component.detectinstance
to verify the component is present. Component.detectinstance
returns false
for the component's view.
This is unlikely to be a bug in Ember. This addon uses some quasi-private APIs to iterate through the booted app's views. The component integration tests are likely rendering in a way that is separate from the app instance, so the app's registered views do not include the stuff you have rendered.
I'll take a look at this.
If we can work out how to make it work (and that may well require changes elsewhere), this would be a very useful feature of testing
@bantic - I'm happy to pair with you on this when you take a look...
@rwjblue thank you for the offer! I am hoping to take a look at it this week, and at minimum this weekend — I will give you a ping.
@BryanCrotaz I've got a version put together in a branch called expect-component-in-integration-tests that passes the tests you've added, but it doesn't work with ember-qunit version 0.4.9 (latest). It does work with version 0.4.1, though, the version you added to this PR. (The current version in this project's bower is 0.3.3, for reference — it needs to be updated).
I'm not clear on the best way to discover rendered views and am looking through the changes to ember-test-helpers to see how best to do this.
For the foreseeable future the "hack" that you've done in these tests (explicitly booting an app, and passing that app to expectComponent
) is going to need to be required. Official Ember Test Helpers are all designed to be used with an explicitly booted app, which isn't the recommended way of writing a component integration test helper.
I'm not sure there is an official way to do integration tests on components yet!
I'm seeing problems elsewhere with ember-qunit
having a dependence on ember-data
. ember-data
appears to have a bug in beta which causes other modules to not be loaded. Is this what you're seeing perhaps?
I'm not sure there is an official way to do integration tests on components yet!
The ember-qunit README describes the suggested/official pattern for component integration tests.
I'm seeing problems elsewhere with ember-qunit having a dependence on ember-data
ember-qunit does not depend on ember-data at all (note no dependencies listed in rwjblue/ember-qunit-builds bower.json).
@BryanCrotaz RWJBlue gave some hints on how to fix this in a way that will work well for both acceptance and integration tests — changing it to use the container directly. I'm going to take a stab at that and this should be fixed soon.
fantastic!
@BryanCrotaz I've released 0.4.0 which should make it possible for you to use expectComponent
in integration tests. See https://github.com/201-created/ember-cli-acceptance-test-helpers/blob/master/tests/integration/expect-component-hbs-integration-test.js for how to write the tests (you do not want to use startApp
, for example).
Note that you'll need to be using ember-qunit version 0.4.7 or later for this to work. Let me know if you have trouble. thanks!
That's so clean. Well played,sir!
Did you recreate my tests in your new branch, or should I submit a new PR with cleaned up tests in the correct form?
@BryanCrotaz There are here: https://github.com/201-created/ember-cli-acceptance-test-helpers/blob/master/tests/integration/expect-component-hbs-integration-test.js Are there any I missed?
No, looks really good.
Upgraded addon to ember 1.13 Added component integration tests to show
expectComponent
doesn't work This demonstrates issue #22