question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Failed unit test with routes

See original GitHub issue

At dummy I have the mounted engine:

this.mount('apollo-enterprise', { as: 'enterprise', path: '/enterprise' });

When I run the tests I get the follow issue:

not ok 47 PhantomJS 2.1 - Unit | Route | reports: it exists
    ---
        actual: >
            null
        expected: >
            null
        stack: >
            missingModule@http://localhost:7357/assets/vendor.js:233:93
            findModule@http://localhost:7357/assets/vendor.js:244:20
            findDeps@http://localhost:7357/assets/vendor.js:178:34
            findModule@http://localhost:7357/assets/vendor.js:248:19
            requireModule@http://localhost:7357/assets/vendor.js:31:25
            _extractDefaultExport@http://localhost:7357/assets/vendor.js:95146:27
            resolveOther@http://localhost:7357/assets/vendor.js:94862:53
            superWrapper@http://localhost:7357/assets/vendor.js:51453:27
            resolveRoute@http://localhost:7357/assets/vendor.js:16051:31
            resolve@http://localhost:7357/assets/vendor.js:15895:43
            _setupIsolatedContainer@http://localhost:7357/assets/test-support.js:7071:66
            setupContainer@http://localhost:7357/assets/test-support.js:6892:39
            http://localhost:7357/assets/test-support.js:5817:32
            initializePromise@http://localhost:7357/assets/vendor.js:69693:15
            Promise@http://localhost:7357/assets/vendor.js:70181:50
            nextStep@http://localhost:7357/assets/test-support.js:5816:54
            invokeSteps@http://localhost:7357/assets/test-support.js:5823:24
            setup@http://localhost:7357/assets/test-support.js:5770:32
            beforeEach@http://localhost:7357/assets/test-support.js:5614:34
            callHook@http://localhost:7357/assets/test-support.js:1478:26
            runHook@http://localhost:7357/assets/test-support.js:1472:15
            advance@http://localhost:7357/assets/test-support.js:1112:26
            begin@http://localhost:7357/assets/test-support.js:2762:27
            http://localhost:7357/assets/test-support.js:1970:11
        message: >
            Promise rejected before "it exists": Could not find module `apollo-enterprise/routes/reports` imported from `dummy/routes/reports`
        Log: |
    ...
ok 48 PhantomJS 2.1 - ESLint - unit/routes/reports-test.js: should pass ESLint

Any idea how solve it? Thanks.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
majew7commented, Sep 5, 2017

We have unit tests working now with two changes, with lazy loaded engines:

  1. It’s necessary to re-export pieces (routes, components, etc) in the app directory, for the purposes for testing.

  2. In tests/index.html this order worked:

    <script src="{{rootURL}}assets/vendor.js"></script>
    <script src="/engines-dist/engine-name1/assets/engine.js"></script>
    <script src="/engines-dist/engine-name1/assets/engine-vendor.js"></script>
2reactions
jbailey4commented, Nov 1, 2017

@majew7 I was able to get my unit tests working in a slightly different way, not any better IMO.

  1. It’s necessary to re-export pieces (routes, components, etc) in the app directory, for the purposes of testing.

I was able to use the ember-engines/test-support/engine-resolver-for module, as specified in the README. The README states its for in-repo-engines, but I’m using it for a stand-alone engine (not sure if that’s due to some other issue I could have 😟).

Also, adding re-exports in the app directory caused module lookup issues when running the engine stand-alone and the engine’s tests.

  1. In tests/index.html this order worked:

I had to do the same.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular Unit testing : Error: Cannot match any routes. URL ...
When you want to unit test your router, you have to use the testing module, not the actual one. Start with import {...
Read more >
Route TestKit • Akka HTTP - Documentation
For services built with the Routing DSL Akka HTTP provides a dedicated testkit that makes efficient testing of route logic easy and convenient....
Read more >
Unit test controller logic in ASP.NET Core
A controller unit test avoids scenarios such as filters, routing, and model binding. Tests that cover the interactions among components that ...
Read more >
Testing
Testing. React Router relies on React context to work. This affects how you can test your components that use our components.
Read more >
getting error trying to unit test my app-route.module.ts #30631
I have an application that hosts 2 other application (a website and dashboard) for my mian application I either redirect to website or ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found