Skip to content
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

Attempting to inject an unknown injection: router:main when running unit or integration tests for controllers or routes. #151

Closed
MiguelMadero opened this issue Apr 13, 2016 · 2 comments

Comments

@MiguelMadero
Copy link

Note: I think this is low priority since there is a workaround (scroll to the bottom), but I still wanted to open it in case someone runs into the same issue.

Easy repro steps:

$ ember new ember new router-main-injection-not-found && \
  cd router-main-injection-not-found && \
  bower install ember#1.11.4  && \
  ember g route dummy-route && \
  ember test

Note: the same error occurs for 1.11, 1.12, route and controller unit tests.

Expected

The tests should pass.

Actual the test fails with the message Attempting to inject an unknown injection:router:main`. Full log:

not ok 10 PhantomJS 2.1 - Unit | Route | dummy route: it exists
    ---
        actual: >
            null
        stack: >
            validateInjections@http://localhost:7357/assets/vendor.js:11622:91
            buildInjections@http://localhost:7357/assets/vendor.js:10772:45
            injectionsFor@http://localhost:7357/assets/vendor.js:10827:37
            factoryFor@http://localhost:7357/assets/vendor.js:10804:37
            lookupFactory@http://localhost:7357/assets/vendor.js:10679:24
            factory@http://localhost:7357/assets/test-support.js:7342:39
            http://localhost:7357/assets/test-support.js:7422:75
            http://localhost:7357/assets/tests.js:153:29
            wrapper@http://localhost:7357/assets/test-support.js:6322:34
            runTest@http://localhost:7357/assets/test-support.js:2502:32
            run@http://localhost:7357/assets/test-support.js:2487:11
            http://localhost:7357/assets/test-support.js:2629:14
            process@http://localhost:7357/assets/test-support.js:2288:24
            begin@http://localhost:7357/assets/test-support.js:2270:9
            http://localhost:7357/assets/test-support.js:2330:9
        message: >
            Died on test #1 testWrapper@http://localhost:7357/assets/test-support.js:6351:16
            test@http://localhost:7357/assets/test-support.js:6364:44
            http://localhost:7357/assets/tests.js:152:24
            exports@http://localhost:7357/assets/vendor.js:92:39
            build@http://localhost:7357/assets/vendor.js:142:17
            findModule@http://localhost:7357/assets/vendor.js:190:14
            requireModule@http://localhost:7357/assets/vendor.js:177:22
            require@http://localhost:7357/assets/test-loader.js:67:16
            loadModules@http://localhost:7357/assets/test-loader.js:58:25
            load@http://localhost:7357/assets/test-loader.js:89:35
            http://localhost:7357/assets/test-support.js:6183:20: Attempting to inject an unknown injection: `router:main`
        Log: |
    ...

Prior to #100 these tests worked fine. zenefits@eb3e171 fixes the issue. {{link-to}} is broken with and without the commit in 1.11 and 1.12.

Based on the description from PR#100 "This ensures they receive no router at all instead of the 1.13-safe one.", I think it's better for those versions to receive a full router instead of no router at all.

Workaround: simply add needs: ['router:main'] to all your route and controller tests or upgrade to 1.13.

MiguelMadero referenced this issue Apr 13, 2016
Versions of Ember prior to 1.13 require a full router booted by the app,
or no router at all. This ensures they receive no router at all instead
of the 1.13-safe one.
@ming-codes
Copy link

I'm getting this as well.

@rwjblue
Copy link
Member

rwjblue commented Jun 20, 2016

Sorry that this has caused you trouble, but I am going to go ahead and close the issue. The work around seems good enough for now, and Ember < 1.13 is getting very long in the tooth at this point...

@rwjblue rwjblue closed this as completed Jun 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants