TypeError: Cannot read property 'generate' of undefined
See original GitHub issueEmber 2.9.0
Running ember test with ember-href-to v1.14.0 is fine. Using v1.15.0 we get some failing integration tests:
actual: >
null
stack: >
TypeError: Cannot read property 'generate' of undefined
at Class.generate (http://localhost:7357/assets/vendor.js:49196:42)
at Class.urlFor (http://localhost:7357/assets/vendor.js:76358:48)
at hrefTo (http://localhost:7357/assets/vendor.js:144238:26)
at Class.compute (http://localhost:7357/assets/vendor.js:144251:23)
at Child.compute (http://localhost:7357/assets/vendor.js:34567:26)
at Child.value (http://localhost:7357/assets/vendor.js:34897:27)
at read (http://localhost:7357/assets/vendor.js:35290:21)
at Object.readArray (http://localhost:7357/assets/vendor.js:35312:16)
at Child.compute (http://localhost:7357/assets/vendor.js:34434:48)
at Child.value (http://localhost:7357/assets/vendor.js:34897:27)
message: >
Died on test #1 at Module.callback (http://localhost:7357/assets/tests.js:27187:24)
at Module.exports (http://localhost:7357/assets/vendor.js:115:32)
at requireModule (http://localhost:7357/assets/vendor.js:36:18)
at TestLoader.<anonymous> (http://localhost:7357/assets/test-support.js:7700:11)
at TestLoader.require (http://localhost:7357/assets/test-support.js:7690:27)
at TestLoader.loadModules (http://localhost:7357/assets/test-support.js:7682:16)
at Function.load (http://localhost:7357/assets/test-support.js:7633:26): Cannot read property 'generate' of undefined
Log: |
The test renders a component that contains a href-to call:
I haven’t manage to recreate it in tests on ember-href-to yet
Issue Analytics
- State:
- Created 6 years ago
- Reactions:5
- Comments:13 (5 by maintainers)
Top Results From Across the Web
Cannot Read Property of Undefined in JavaScript - Rollbar
TypeError: Cannot read property of undefined occurs when a property is read or a function is called on an undefined variable.
Read more >Uncaught TypeError: Cannot read property of undefined In
Uncaught TypeError: Cannot read property of undefined error occurs in Chrome when you read a property or call a method on an undefined...
Read more >Why does Javascript generate "Uncaught TypeError: Cannot ...
Why does Javascript generate "Uncaught TypeError: Cannot read property of undefined" if this property is defined? · Subscribe to RSS.
Read more >How to Avoid the Infamous "Cannot read properties of ... - Bitovi
Interpreting undefined or null as subtypes of all other types can lead to runtime problems. For example, if you try to get the...
Read more >TypeError: Cannot read property 'startsWith' of undefined
TypeError : Cannot read property 'startsWith' of undefined: D:\codespace\zzz\node_modules\mongodb-connection-string-url\lib\index.js:9 return ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Looking around some more, it looks like the integration test is setting up the router with:
@GavinJoyce Is there a way to automatically setup the router without needing to manually add a beforeEach to every integration test?
I was seeing this on 1.15.x with ember@2.17.1. Looking into this some it looks like the router isn’t setup yet, that’s why
this._routerMicrolib
is undefined.this._routerMicrolib
is setup in the_initRouterJs
method. My guess is that the router isn’t setup in component tests.Reference: https://github.com/emberjs/ember.js/blob/master/packages/ember-routing/lib/system/router.js#L396