管道编号导致业力崩溃

Pipe Number cause karma to crash

使用 Pipe Number case karma 使负载组件失效

当我移除管道时测试通过

但是在应用程序中一切正常

这是我在模板中使用管道的方式

{{ facture | number:'0.2':'fr' }}

{{ facture | currency:'EUR':'symbol':'0.2-2':'fr' }}

如果我把所有测试都通过,除了我没有得到正确的格式

 {{ facture }}

这是我的测试配置

import { CurrencyPipe, DecimalPipe, PercentPipe } from '@angular/common';


fdescribe('MontantFacturesComponent', () => {
  const contentTitle: String = 'Choisissez les factures à payer' ;
  const facturesUpdate: String = '30 Octobre 2018 à 18:52:48' ;
  const factureTotal: String = '232,40' ;

  let component: MontantFacturesComponent;
  let fixture: ComponentFixture<MontantFacturesComponent>;
  let componentEL: DebugElement ;

  let contentTitleEL: DebugElement ;
  let nomClient: DebugElement ;
  let numClient: DebugElement ;

  let factureHead: DebugElement ;
  let factureBody: DebugElement ;
  let factureFoot: DebugElement ;

  beforeEach(async(() => {
    const comp = TestBed.configureTestingModule({
      imports: [
        NgbModule.forRoot(),
        AngularFontAwesomeModule,
        RouterModule.forRoot(<Routes>[]), 
        HttpClientModule, 
      ],
      declarations: [ 
        MontantFacturesComponent,
      ],
      providers : [
        AppService,
        {provide: APP_BASE_HREF, useValue : '/' },
        CommonModule,
        CurrencyPipe, DecimalPipe, PercentPipe
      ]
    }) ;

    // Configure the component with another set of Providers
    TestBed.overrideComponent(
        MontantFacturesComponent,
        {set: {providers: [{provide: AppService, useClass: MockAppService}]}}
    );
    comp.compileComponents();
  }));

有或没有管道供应商 commonModule 没有变化

        CommonModule,
        CurrencyPipe, DecimalPipe, PercentPipe

当我的模板中有管道时,看起来我的整个组件都未定义

Uncaught Error: Unexpected module 'CommonModule' declared by the module

 'DynamicTestModule'. Please add a @Pipe/@Directive/@Component annotation.

貌似是使用local的问题fr

两个

{{factureTotal | currency:'EUR':'symbol':'0.2-2':'fr'}}

{{factureTotal | currency:'EUR':'symbol':'0.2-2':'fr-FR'}}

失败但

{{factureTotal | currency:'EUR':'symbol':'0.2-2'}}

知道如何使因果报应起作用吗

经过一周的查找发现了问题

karma 似乎没有加载本地格式

import { registerLocaleData } from '@angular/common';
import localeFr from '@angular/common/locales/fr';
registerLocaleData(localeFr);

这解决了导致 testComponent 崩溃的问题