-
-
Notifications
You must be signed in to change notification settings - Fork 257
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
Adding standalone integration test support #21
Conversation
self.view = Ember.View.create({ | ||
context: self, | ||
controller: self, | ||
template: Ember.Handlebars.compile(templateString), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should allow for a precompiled template to be passed in. I can't recall if Ember.Handlebars.compile
properly handles a precompiled template...
The view created in |
I'd like to make https://github.com/switchfly/ember-test-helpers/blob/master/lib/ember-test-helpers/test-module.js#L99-L101, create the container as you have here if a Thoughts? |
There is a bad assumption baked into the existing nomenclature, which is that components should get unit tests and not integration tests. I think that is often the wrong default choice, which is why people keep hitting frustration around And I don't think just having an Just to pick one example, consider block param handling: this.render(`
{{#my-component as |value|}}
<div class="sample">{{value}}</div>
{{/my-component}}
`);
equal(this.$('.sample').text(), 'correctValue'); I'm not even sure how you'd write that test using I'm not a fan of |
Nothing about the current API makes it unit testing, other than that is what we have generally called it. Specifying tldr; I am not suggesting that adding |
That sounds fine. We can merge this and then refactor the non-isolated container into a shared place. I agree that the existing moduleFor with a non-isolated container is needed for services & models. I would still favor replacing the existing moduleForComponent with this, so we're not leading newbies down the wrong path. But that decision does not need to be made now. We can ship this new option and see how it's adopted. |
I agree 100%. |
I'm 👍 on landing this now, and refactoring the isolated container bits into @dgeb - Can you review and 👍 / 👎 also? |
@ef4 thanks for this! I agree that an integration testing module has been sorely missing. I am 👍 on merging. Integration vs. unit tests don't have to be an either / or decision: I believe both should be created by model and component generators. |
love it. |
Adding standalone integration test support
Once we have a release here I will submit PRs to ember-qunit and ember-mocha. |
Some ideas: What if the generated skeleton was for a unit test, but told you how to "upgrade" to an integration test? // If you want access to integration test helpers like `click`, change
// `moduleForComponent` to `integrationModuleForComponent`.
moduleForComponent('foo-bar', 'FooBarComponent');
test('it exists', function(assert) {
assert.ok(true);
}); Alternatively, what if the install integration test helpers action was performed like the current moduleForComponent('foo-bar', 'FooBarComponent', {
setup: function() {
// Uncomment if you need integration test helpers like click()
// this.needsIntegrationTestHelpers();
}
}); Lastly, a related, but different question: how would |
This does require the template compiler. I think ember-cli should ship the compiler in the test support bundle by default, but with the important caveat that it should be available as module you can explicitly import, not as a global that app code can accidentally depend on, causing tests to pass that should have failed. |
That caveat is king here. I've been burned by "accidentally" depending on the template compiler more than once. I'd prefer to get a good ES6 template string setup and still precompile in node-land. I said more things here: ember-cli/ember-cli#3497 (comment) |
That would be nice. Seems like a good use of es6 tagged template strings.
|
This adds a new kind of test module that fills a gap in the current set of possible tests. So far we have:
But we're missing the ability to integration test a unit smaller than whole-application. This PR adds a new
TestModuleForIntegration
that lets you drive an integration test with a template. I think this is often a more appropriate way to test Ember Components than a unit test, because interesting components tend to have rich dependence on other components.The included tests illustrate the basic use cases: rendering a template, setting values in its context, and handling its events.