如果有人创建了具有jQWidgets的jasmine / karma Angular测试 - 即使您没有遇到此错误,我也希望看到您的karma.conf.js和.spec文件,因为我遇到了问题 .
我可以很好地为应用程序提供服务 - 应用程序只是Angular提供的启动程序 - 但是我的.spec单元测试组件会在业力中引发此错误:
Failed: Unexpected value ‘undefined’ declared by the module ‘DynamicTestModule’
在我的spec文件中:
import { TestBed, async } from '@angular/core/testing';
import { AppComponent } from './app.component';
import { jqxGridComponent } from 'jqwidgets-scripts/jqwidgets-ts/angular_jqxgrid';
describe('AppComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [jqxGridComponent, AppComponent]
}).compileComponents();
}));
it('app dummy test', () => {
expect(1).toBe(2);
});
});
app.component.ts:
import { Component } from '@angular/core';
import { jqxGridComponent } from 'jqwidgets-scripts/jqwidgets-ts/angular_jqxgrid';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
constructor() {}
}
app.module.ts:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { jqxGridComponent } from 'jqwidgets-scripts/jqwidgets-ts/angular_jqxgrid';
@NgModule({
declarations: [AppComponent, jqxGridComponent],
imports: [BrowserModule],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule {}
我很感激任何帮助和/或工作jqWidget测试的例子 .
1 回答
在tsconfig.spec.json中,包含jqwidgets文件路径: