blueprints/instance-initializers-test: Add RFC232 variants#15945
blueprints/instance-initializers-test: Add RFC232 variants#15945rwjblue merged 2 commits intoemberjs:masterfrom
Conversation
abb48b3 to
5822a13
Compare
5822a13 to
8156867
Compare
rwjblue
left a comment
There was a problem hiding this comment.
I’d like to restructure things a bit, I left an example in line would you mind giving that snippet a whirl and confirming that it works properly? I believe it should (barring any typos etc)
|
|
||
| // Replace this with your real tests. | ||
| test('it works', function(assert) { | ||
| initialize(this.application); |
There was a problem hiding this comment.
Instance initializers expect to receive an Ember.ApplicationInstance instance, but this is an Ember.Application instance.
There was a problem hiding this comment.
To fix that, you would do something like:
module(‘asdf’, function(hooks) {
hooks.beforeEach(function() {
this.Application = Ember.Application.extend();
this.application = this.Application.create({ autoboot: true });
this.application.instanceInitializer({
name: ‘initializer under test’,
initialize
});
});
hooks.afterEach(function() {
runDestroy(this.instance);
runDestroy(this.application);
});
test(‘it works’, async function(assert) {
this.instance = this.application.buildInstance();
await this.instance.boot();
assert.ok(didTheInitializerWork);
});
});
There was a problem hiding this comment.
@rwjblue Ah yeah overall my bad. So with this test, await this.instance.boot(); results in Assertion Failed: You cannot use the same root element (BODY) multiple times in an Ember.Application. Failing on this line -
There was a problem hiding this comment.
tested on a 2.17 application.
There was a problem hiding this comment.
Would you mind pushing up your demo app so I can tinker with it to find the right combo?
There was a problem hiding this comment.
Also, I made a really bad mistake in my comment above, it should be { autoboot: false } (and I had true in the comment)
There was a problem hiding this comment.
OK, just tested locally, and I think that it will work once updating to { autoboot: false } (sorry about that).
|
|
||
| hooks.beforeEach(function() { | ||
| run(() => { | ||
| this.application = Application.create(); |
There was a problem hiding this comment.
Can you swap this to Application.create({ autoboot: false }) here?
| hooks.beforeEach(function() { | ||
| run(() => { | ||
| this.application = Application.create(); | ||
| this.application.deferReadiness(); |
There was a problem hiding this comment.
This shouldn’t be needed with my suggested changes
| setupTest(hooks); | ||
|
|
||
| hooks.beforeEach(function() { | ||
| run(() => { |
There was a problem hiding this comment.
We shouldn’t need to Ember.run here, why is this required? Is there an error or something without it?
There was a problem hiding this comment.
Yeah the error I get is the You have turned on testing mode... error...specifically related to the Application.create() expression.
|
Awesome, thank you! |
Progress on #15933