Ember-simple-auth: Attempting to inject an unknown injection: 'service:session' error

Created on 16 Mar 2017  路  1Comment  路  Source: simplabs/ember-simple-auth

We're having an error that seems ember-simple-auth related. We're using the latest version of this package (1.2.0) and Ember CLI 2.11. However, this error appeared when we ran npm update for our project, which only updated these 4 packages:

[email protected] 
[email protected] 
[email protected] 
[email protected]

Here I show:

  • The application route file where we inject the session
  • It's unit test
  • The error message

Files

// application/route.js
import Ember from 'ember';

const { inject } = Ember;

export default Ember.Route.extend({
  session: inject.service('session'),
  ...
});
// tests/unit/application/route-test.js
import { moduleFor, test } from 'ember-qunit';

moduleFor('route:application', 'Unit | Route | application', {
  // Specify the other units that are required for this test.
  // needs: ['controller:foo']
});

test('it exists', function(assert) {
  let route = this.subject();
  assert.ok(route);
});

Error message

not ok 219 PhantomJS 2.1 - Unit | Route | application: it exists
    ---
        actual: >
            null
        expected: >
            null
        stack: >
            validateInjections@http://localhost:7357/assets/vendor-41af9909184e8c47647ae377b51c18ba.js:18089:93
            http://localhost:7357/assets/vendor-41af9909184e8c47647ae377b51c18ba.js:17389:54
            runInDebug@http://localhost:7357/assets/vendor-41af9909184e8c47647ae377b51c18ba.js:21610:9
            runInDebug@http://localhost:7357/assets/vendor-41af9909184e8c47647ae377b51c18ba.js:33272:43
            create@http://localhost:7357/assets/vendor-41af9909184e8c47647ae377b51c18ba.js:17381:29
            defaultSubject@http://localhost:7357/assets/test-support-9017f32a5182cdc17f4058714d8c196b.js:7234:30
            http://localhost:7357/assets/test-support-9017f32a5182cdc17f4058714d8c196b.js:7269:43
            http://localhost:7357/assets/tests-a6f5799bf9877246a828866d0581c8b2.js:2862:29
            runTest@http://localhost:7357/assets/test-support-9017f32a5182cdc17f4058714d8c196b.js:1292:34
            run@http://localhost:7357/assets/test-support-9017f32a5182cdc17f4058714d8c196b.js:1278:13
            http://localhost:7357/assets/test-support-9017f32a5182cdc17f4058714d8c196b.js:1456:15
            process@http://localhost:7357/assets/test-support-9017f32a5182cdc17f4058714d8c196b.js:2690:26
            begin@http://localhost:7357/assets/test-support-9017f32a5182cdc17f4058714d8c196b.js:2673:11
            http://localhost:7357/assets/test-support-9017f32a5182cdc17f4058714d8c196b.js:1890:11
        message: >
            Died on test #1 http://localhost:7357/assets/tests-a6f5799bf9877246a828866d0581c8b2.js:2861:24
            exports@http://localhost:7357/assets/vendor-41af9909184e8c47647ae377b51c18ba.js:123:37
            requireModule@http://localhost:7357/assets/vendor-41af9909184e8c47647ae377b51c18ba.js:38:25
            require@http://localhost:7357/assets/test-support-9017f32a5182cdc17f4058714d8c196b.js:5188:14
            loadModules@http://localhost:7357/assets/test-support-9017f32a5182cdc17f4058714d8c196b.js:5180:21
            load@http://localhost:7357/assets/test-support-9017f32a5182cdc17f4058714d8c196b.js:5210:33
            http://localhost:7357/assets/test-support-9017f32a5182cdc17f4058714d8c196b.js:5094:22: Attempting to inject an unknown injection: 'service:session'
invalid

Most helpful comment

You are missing needs: ['service:session'] in the unit test. Other than most people (including me until a few weeks ago) are thinking, injected instances must be available when the instance they are injected to is created. That has always been the case but the assertion has only recently been added to Ember.js.

>All comments

You are missing needs: ['service:session'] in the unit test. Other than most people (including me until a few weeks ago) are thinking, injected instances must be available when the instance they are injected to is created. That has always been the case but the assertion has only recently been added to Ember.js.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

arenoir picture arenoir  路  4Comments

st-h picture st-h  路  6Comments

dr0pdb picture dr0pdb  路  8Comments

Sinled picture Sinled  路  5Comments

romulomachado picture romulomachado  路  6Comments