-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
[FEATURE] Support for ApplicationInstances in test helpers #12310
Conversation
}); | ||
|
||
EmberApplicationInstance.reopen({ | ||
injectTestHelpers() { |
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.
This function and ApplicationInstance#removeTestHelpers
are super similar to the same functions on Application
, I was unsure if I should extract them out though as they differ on a couple lines
a89a98d
to
60582b1
Compare
@stefanpenner @rwjblue this is ready for an initial review. Primary concern I have is the extent to test the instance-based approach, as I could duplicate all the current test helper tests, but that seems a bit ridiculous. |
|
||
function currentRouteName(app) { | ||
var appController = lookup(app, 'controller:application'); |
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.
Unrelated to this PR directly, but we should update these to use service:-routing
instead of controller:application
.
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.
I'll open a separate PR for that once this work is finished.
A few notes:
// in ember-qunit or ember-test-helpers
for (var helperName in this.instance.testHelpers) {
this[helperName] = function() {
this.instance.testHelpers[helperName](...arguments);
}
}
// allows the following
test('visted foo', function(assert) {
this.visit('foo');
}); |
I'll make those changes. I think leaving the mapping of the helpers to a more convenient location up to other libraries is fine. Chances are |
6aad2b2
to
62c3adb
Compare
@rwjblue updated with your requested changes. Also duplicated the current There is one issue that I can't seem to solve, and that is the test with a redirect in it keeps failing. It doesn't seem to pick up on the intermediate transition and thus exits the test before all the assertions have been made. I'll keep digging, but would appreciate any thoughts on the matter. |
62c3adb
to
1e8568e
Compare
Figured out the last issue, was calling the wrong |
ah this was my question, so we follow up with ember-test-helpers PR to make this fancy. |
|
||
this.testHelpers = {}; | ||
for (var name in helpers) { | ||
this.testHelpers[name] = helper(this, name); |
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.
I'm not really a fan of all this copying, but without a large refactoring i dont see a quick fix.
One idea, is rather then copying, the test frameworks gives us a TestHelpers object, something like
this.testHelpers = new TestHelpers(applicationInstance);
// internally, this.testHelpers now has a reference to the app instance, and can just do the right thing internally.
this LGTM |
@rwjblue think this can this get merged? |
@trentmwillis - Will try to review in detail tonight, sorry for the delays. |
c1ff82e
to
2042c6b
Compare
Rebased to get the latest changes in. @rwjblue any time to check this out soon? |
Just did another pass, this looks good. My existing comments stands, but we can always address that later. It's important somewhere, to bring attention to the fact that we don't (at least that is my understandating) actually intend the end user to use |
we may have some overlap with: #12394 @chancancode r? |
2042c6b
to
a7941d1
Compare
@stefanpenner @rwjblue had some time to revisit this and update it to take into consideration @chancancode's changes. Hoping we can finally get this in soon. |
ab35dab
to
4bcef8e
Compare
4bcef8e
to
50f7799
Compare
Looks like I finally managed to get the tests passing (other than one version of IE that timed out on Sauce Labs). I'm not 100% sure why, but the |
☔ The latest upstream changes (presumably #12766) made this pull request unmergeable. Please resolve the merge conflicts. |
fd4166e
to
693c651
Compare
☔ The latest upstream changes (presumably #12772) made this pull request unmergeable. Please resolve the merge conflicts. |
693c651
to
c1c881d
Compare
@stefanpenner or @rwjblue rebased again, can either of you take a look at this? Or if it's been decided to not support this use case I'll close the PR |
+1 Would love to see this get merged. Watching Trent's local copy of Ember, with this change applied, cruise through acceptance tests while my default copy slowly churned through those same tests was eye opening. |
☔ The latest upstream changes (presumably #12575) made this pull request unmergeable. Please resolve the merge conflicts. |
Let me give it a read. I do believe we want this, sorry for letting it slip |
Example: | ||
|
||
```javascript | ||
var instance = run(App, 'buildTestInstance'); |
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.
i wonder if we should do a run.join inside of this method, so we don't need to enforce the external run.
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.
I'd be fine with that. Currently chose this approach to keep it similar to how start-app
works.
I'd like to have a meeting to discuss with @trentmwillis, @mmun, and I. Basically, I'd rather focus on implementing a new wholistic testing setup (will try to write the RFC tonight), and eventually completely remove/deprecate packages/ember-testing after a migration and wind down period (certainly supported through 3.0.0 though). |
@rwjblue I think that is a good goal, though I would like to see this feature come sooner rather than later. I do, however, understand wanting to keep churn down and not introduce multiple major testing changes. So, let's talk sometime soon. |
@rwjblue @trentmwillis One constraint I'd love for you guys to take into account when designing a holistic new test API is to not surface the concept of "application instance" to new developers. It's just a concept that is very useful for internals but adds complexity to the end user. As discussed above, just do |
Yes, agreed. It is a mega troll that we have Application instances and ApplicationInstance instances. We should not force the mental pain upon anyone else. |
Closing this in favor of emberjs/rfcs#119. |
Addresses #12277. Adds the following:
Application#buildTestInstance
, which creates a new instance of an application and registers test helpers on it.ApplicationInstance#injectTestHelpers
andApplicationInstance#removeTestHelpers
which are similar to the same name methods onApplication
, but bind the test helpers to the instanceTodo: