我正在编写一个angular 2应用程序,并且正在使用我们的UI团队的库。应用程序的开发进展顺利,我可以通过使用类似import语句轻松使用其所有组件。这是我的app.module.ts:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { SohoComponentsModule } from '@infor/sohoxi-angular'; // This is the one in question.
import { AppComponent } from './app.component';
import { licenseGeneratorComponent } from './licenseGenerator.component';
import { emergencyLicenseComponent } from './tabs/emergency/emergencyLicense.component';
import { partnerLicenseComponent } from './tabs/partner/partnerLicense.component';
import { standardLicenseComponent } from './tabs/standard/standardLicense.component';
@NgModule({
declarations: [
AppComponent,
licenseGeneratorComponent,
emergencyLicenseComponent,
partnerLicenseComponent,
standardLicenseComponent
],
imports: [
BrowserModule,
FormsModule,
HttpModule,
SohoComponentsModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
这是我在这个应用程序中使用的模板之一,soho的东西来自这个库:
<div class="row">
<div class="twelve columns">
<h1>License Generator</h1>
<div soho-tabs>
<ul soho-tab-list>
<li soho-tab><a soho-tab-title tabId='tabs-normal-emergency'>Emergency Licenses</a></li>
<li soho-tab><a soho-tab-title tabId='tabs-normal-partner'>Partner Licenses</a></li>
<li soho-tab><a soho-tab-title tabId='tabs-normal-standard'>Standard Licenses</a></li>
</ul>
<div soho-tab-panel tabId='tabs-normal-emergency'>
<emergency-license></emergency-license>
</div>
<div soho-tab-panel tabId='tabs-normal-partner'>
<partner-license></partner-license>
</div>
<div soho-tab-panel tabId='tabs-normal-standard'>
<standard-license></standard-license>
</div>
</div>
</div>
</div>
该应用程序一直运行良好,没有问题。但是,当我的单元测试出现问题时。我让他们在进行前几个单元测试之前就工作了,但是将其搁置了一个星期左右,并添加了更多内容,现在测试无法正常运行。
当我运行测试时,我得到了错误
Unexpected value 'SohoComponentsModule' imported by the module 'DynamicTestModule'
我的app.component.spec看起来像这样:
import { TestBed, async } from '@angular/core/testing';
import { FormsModule } from '@angular/forms';
import { AppComponent } from './app.component';
import { licenseGeneratorComponent } from './licenseGenerator.component';
import { emergencyLicenseComponent } from './tabs/emergency/emergencyLicense.component';
import { partnerLicenseComponent } from './tabs/partner/partnerLicense.component';
import { standardLicenseComponent } from './tabs/standard/standardLicense.component';
import { SohoComponentsModule } from '@infor/sohoxi-angular';
describe('AppComponent', () => {
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [
AppComponent,
licenseGeneratorComponent,
emergencyLicenseComponent,
partnerLicenseComponent,
standardLicenseComponent,
],
imports: [
FormsModule,
SohoComponentsModule
],
});
});
it('should create the app', async(() => {
let fixture = TestBed.createComponent(AppComponent);
let app = fixture.debugElement.componentInstance;
expect(app).toBeTruthy();
}));
it(`should have as title 'app works!'`, async(() => {
let fixture = TestBed.createComponent(AppComponent);
let app = fixture.debugElement.componentInstance;
expect(app.title).toEqual('app works!');
}));
});
我现在绕圈了,因为如果我在测试中删除了import语句,则会引发以下错误:
Can't bind to 'closeOnSelect' since it isn't a known property of 'select'. ("label required">Versions</label>
请帮忙!
请记住,该应用程序仍然可以正常工作,只是给我带来问题的单元测试。我整天都在寻找修复程序,但无法弄清楚。
请让我知道是否需要发布更多文件。谢谢克里斯
出于某种原因,导致此问题的是角度库。我更新了版本,此问题已解决。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句