Instance initializer unit test fails with "store is undefined"
<p>After generating an example application:</p>

<pre><code>ember new preloadtest
cd preloadtest/
ember g instance-initializer preload
ember g model test-data
ember g route index
ember g adapter application
</code></pre>

<p>With the following files:</p>

<p><strong>models/test-data.js</strong></p>

<pre><code>import DS from 'ember-data';

export default DS.Model.extend({
  name: DS.attr('string'),
  value: DS.attr( 'number' )
});
</code></pre>

<p><strong>routes/index.js</strong></p>

<pre><code>import Ember from 'ember';

export default Ember.Route.extend({
  model(){
    return this.store.peekAll( 'test-data' );
  }
});
</code></pre>

<p><strong>instance-initializers/preload.js</strong></p>

<pre><code>export function initialize( appInstance ) {
  let store = appInstance.lookup( 'service:store' );
  store.pushPayload( { "testDatas": [
    { "id": 1, "name": "aaa", "value": 1},
    { "id": 2, "name": "bbb", "value": 2},
    { "id": 3, "name": "ccc", "value": 3}
  ] } );
}

export default {
  name: 'preload',
  initialize
};
</code></pre>

<p><strong>templates/index.hbs</strong></p>

<pre><code>&lt;ul&gt;
{{#each model as |td|}}
  &lt;li&gt;{{td.name}}: {{td.value}}&lt;/li&gt;
{{/each}}
&lt;/ul&gt;
</code></pre>

<p><strong>adapters/application.js</strong></p>

<pre><code>import RESTAdapter from 'ember-data/adapters/rest';

export default RESTAdapter.extend({});
</code></pre>

<p><code>ember serve</code> runs the application and displays the preload data but going to <code>/tests</code> the default unit test for the <code>preload</code> instance initializer fails with the error <code>store is undefined</code>.</p>

<p><strong>Full Error Message</strong>:</p>

<pre><code>Died on test #1 @http://localhost:4200/assets/tests.js:212:1
Module.prototype.exports@http://localhost:4200/assets/vendor.js:94:20
Module.prototype.build@http://localhost:4200/assets/vendor.js:142:5
findModule@http://localhost:4200/assets/vendor.js:193:5
requireModule@http://localhost:4200/assets/vendor.js:181:12
TestLoader.prototype.require@http://localhost:4200/assets/test-loader.js:67:9
TestLoader.prototype.loadModules@http://localhost:4200/assets/test-loader.js:58:13
TestLoader.load@http://localhost:4200/assets/test-loader.js:89:7
@http://localhost:4200/assets/test-support.js:6397:5
: store is undefined@ 114 ms
Source:     

initialize@http://localhost:4200/assets/preloadtest.js:213:5
@http://localhost:4200/assets/tests.js:213:1
runTest@http://localhost:4200/assets/test-support.js:2716:14
Test.prototype.run@http://localhost:4200/assets/test-support.js:2701:4
run/&lt;@http://localhost:4200/assets/test-support.js:2843:6
process@http://localhost:4200/assets/test-support.js:2502:4
begin@http://localhost:4200/assets/test-support.js:2484:2
resumeProcessing/&lt;@http://localhost:4200/assets/test-support.js:2544:4
</code></pre>

<p>How do I initialize the application's store so that it can be used in the unit test?</p>

<p><strong>Edit - tests/unit/instance-initializers/preload-test.js</strong></p>

<pre><code>import Ember from 'ember';
import { initialize } from 'preloadtest/instance-initializers/preload';
import { module, test } from 'qunit';
import destroyApp from '../../helpers/destroy-app';
//import DS from 'ember-data';

module('Unit | Instance Initializer | preload', {
  //needs: [ 'service:store' ],
  beforeEach: function() {
    Ember.run(() =&gt; {
      this.application = Ember.Application.create();
      this.appInstance = this.application.buildInstance();
    });
  },
  afterEach: function() {
    Ember.run(this.appInstance, 'destroy');
    destroyApp(this.application);
  }
});

// Replace this with your real tests.
test('it works', function(assert) {
  initialize(this.appInstance);

  // you would normally confirm the results of the initializer here
  assert.ok(true);
});
</code></pre>

<p>Tried it with <code>needs: [ 'service:store' ]</code> and without (although its suggested that you <a href="https://github.com/emberjs/data/issues/2994#issuecomment-99615466">should not need to do this</a> if Ember-Data is on the page - which I've also tried importing both in the unit test and in the instance initialiser).</p>

<p><strong>Versions</strong>:</p>

<pre><code>Ember      : 2.4.5
Ember Data : 2.5.2
</code></pre>