简体   繁体   English

FOSJsRoutingBundle&Karma:该路线不存在

[英]FOSJsRoutingBundle & Karma: The route does not exist

I started writing tests for my huge AngularJS application. 我开始为庞大的AngularJS应用程序编写测试。 I used Router.generate() everywhere in my application. 我在应用程序中的任何地方都使用了Router.generate()。

First time I got this Router is not defined 我第一次得到这个Router is not defined

So, I added a router.js to my karma.conf.js 所以,我添加了一个router.jskarma.conf.js

files: [
  './web/vendor/angular/angular.js',
  './node_modules/angular-ui-router/release/angular-ui-router.js',
  './web/bundles/fosjsrouting/js/router.js',
  './node_modules/angular-mocks/angular-mocks.js',
  './web/assets/js/**/*.js', // all project files
  './web/assets/js/app.js', // app where angular.module defined
  './web/assets/tests/**/*.js' // is where all tests placed
],

And now I end up with 'The route "api_get_users" does not exist' , as I understand api_get_users is a first Router.generate call encountered by Karma while loading files. 现在我结束了'The route "api_get_users" does not exist' ,因为我知道api_get_users是Karma在加载文件时遇到的第一个Router.generate调用。

As I may understand the error is going from routing bundle, not from Karma, so it unable to find list of available routes and I'm not really understand how can I pre-load those routes. 据我所知,错误是来自路由束,而不是来自Karma,因此它无法找到可用路由列表,而且我不太了解如何预加载这些路由。

Please, help me to find a way out. 请帮我找到一个出路。

Oh! 哦! I found an answer so far, hope this would be helpful 我到目前为止找到了答案,希望这会有所帮助

just generate a routes as shown in tutorial and then include fos_js_routes.js file into Karma files section 只需生成教程中所示的路线,然后将fos_js_routes.js文件包含在Karma files部分中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM