zoukankan      html  css  js  c++  java
  • [Angular] Using NO_ERRORS_SCHEMA

    For example, when testing container component we might import lots of children components, but we didn't actually testing those children components. So we don't need to provide all those stuff:

        TestBed.configureTestingModule({
          imports: [
            ReactiveFormsModule
          ],
          declarations: [
            StockBranchComponent,
            StockCounterComponent,
            StockProductsComponent,
            StockSelectorComponent,
            StockInventoryComponent
          ],
          providers: [
            {provide: StockInventoryService, useClass: MockStockInventoryService }
          ]
        })

    One way to sovle this is by providing '

    NO_ERRORS_SCHEMA

    '

    import { DebugElement, NO_ERRORS_SCHEMA } from '@angular/core';
    
        TestBed.configureTestingModule({
          imports: [
            ReactiveFormsModule
          ],
          declarations: [
            StockInventoryComponent
          ],
          schemas: [NO_ERRORS_SCHEMA],
          providers: [
            { provide: StockInventoryService, useClass: MockStockInventoryService }
          ]
        });
  • 相关阅读:
    [国家集训队] Crash 的文明世界
    [国家集训队] middle
    [正睿集训2021] 构造专练
    [正睿集训2021] LIS
    CF482E ELCA
    UVA
    UVA
    UVA
    UVA
    UVA
  • 原文地址:https://www.cnblogs.com/Answer1215/p/6833415.html
Copyright © 2011-2022 走看看