Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/haskell/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular ui router Can';t解析UIRouter的所有参数:(?,?)_Angular Ui Router_Karma Jasmine - Fatal编程技术网

Angular ui router Can';t解析UIRouter的所有参数:(?,?)

Angular ui router Can';t解析UIRouter的所有参数:(?,?),angular-ui-router,karma-jasmine,Angular Ui Router,Karma Jasmine,我使用angular2和uirouter进行路由。我已经在应用程序中成功地实现了uirouter模块,但是当我尝试测试我的应用程序时,问题出现了。在这里,我使用karma,Jasmin,并使用npm测试启动它。但遇到错误:无法解析UIRouter:(?,?)的所有参数。 我已经在*.spec.ts文件中导入了“UIRouter”,并将其添加到providers数组中,如下所示 import { UIRouterModule } from '@uirouter/angular'; import {

我使用angular2和uirouter进行路由。我已经在应用程序中成功地实现了uirouter模块,但是当我尝试测试我的应用程序时,问题出现了。在这里,我使用karma,Jasmin,并使用npm测试启动它。但遇到
错误:无法解析UIRouter:(?,?)的所有参数。

我已经在
*.spec.ts
文件中导入了“UIRouter”,并将其添加到providers数组中,如下所示

import { UIRouterModule } from '@uirouter/angular';
import { UIRouter } from "@uirouter/core";
describe('Footer Menus', () => {
  let footerMenuBlServiceRef:FooterMenuBLService;
  beforeEach(async(() => {
    TestBed.configureTestingModule({
      imports: [],
      declarations: [],
      providers: [UIRouter],
    })
      .compileComponents();
  }));
但是没有运气。任何帮助都将不胜感激

解决了它!!! 只需从
providers
数组中删除
UIRouter
,但保留导入语句。是的,它起作用了。

解决了它!!!
只需从
providers
数组中删除
UIRouter
,但保留导入语句。是的,它确实起作用了。

上周五,我终于找到了让它起作用的方法。这不是一个干净的方法,但至少是有效的

我使用功能模块的状态重新导入UIRouter.forRoot,并为UIRouter的根提供程序提供APP_BASE_HREF值

以下是我的简历:

beforeEach(async(() => {
    TestBed.configureTestingModule({
        declarations: [
            HomeComponent,
            HomeCardComponent
        ],
        imports: [
            AppMaterialModule,
            // Always import root UIRouter module when testing a component including routing
            UIRouterModule.forRoot({states: HOME_STATES})
        ],
        providers: [
            // Also, include the base href value when testing a component including routing
            {provide: APP_BASE_HREF, useValue: '/'}
        ],
    }).compileComponents();
}));

如果你知道更好的方法,我很乐意知道!:)

上周五,我终于找到了一个办法让它发挥作用。这不是一个干净的方法,但至少是有效的

我使用功能模块的状态重新导入UIRouter.forRoot,并为UIRouter的根提供程序提供APP_BASE_HREF值

以下是我的简历:

beforeEach(async(() => {
    TestBed.configureTestingModule({
        declarations: [
            HomeComponent,
            HomeCardComponent
        ],
        imports: [
            AppMaterialModule,
            // Always import root UIRouter module when testing a component including routing
            UIRouterModule.forRoot({states: HOME_STATES})
        ],
        providers: [
            // Also, include the base href value when testing a component including routing
            {provide: APP_BASE_HREF, useValue: '/'}
        ],
    }).compileComponents();
}));
如果你知道更好的方法,我很乐意知道!:)

UI路由器可能会有所帮助。这就是我的工作原理:

import { UIRouterModule } from '@uirouter/angular';
...
TestBed.configureTestingModule({
    ...
    imports: [UIRouterModule.forRoot({ useHash: true })],
})
UI路由器可以提供一些帮助。这就是我的工作原理:

import { UIRouterModule } from '@uirouter/angular';
...
TestBed.configureTestingModule({
    ...
    imports: [UIRouterModule.forRoot({ useHash: true })],
})

嗨,希夫!你能详细介绍一下你的决议吗?我有同样的问题,你的回答并没有帮助我解决我的问题。我的模块中有UIRouterModule.forChild,我不知道如何在规范文件中模拟它。谢谢你的帮助:)嘿,Pitchou,请你添加你的规范文件代码,以便更好地澄清你的问题。我只需要你的导入和每个函数之前的数据。嗨,希夫!你能详细介绍一下你的决议吗?我有同样的问题,你的回答并没有帮助我解决我的问题。我的模块中有UIRouterModule.forChild,我不知道如何在规范文件中模拟它。谢谢你的帮助:)嘿,Pitchou,请你添加你的规范文件代码,以便更好地澄清你的问题。我只需要你的导入和每个函数之前的数据。