简体   繁体   English

错误:“NG0303:无法绑定到‘max’,因为它不是‘mat-progress-bar’的已知属性。” 同时 angular 测试

[英]ERROR: 'NG0303: Can't bind to 'max' since it isn't a known property of 'mat-progress-bar'.' while angular testing

component.spec file component.spec 文件

trying to test a component nut keep getting these messages in terminal.试图测试组件坚果不断在终端中获取这些消息。 It does not fail the test but gives error like a warning.它不会通过测试,但会像警告一样给出错误。 Could anyone provide a solution here.谁能在这里提供解决方案。 I am importing all the required modules here.我在这里导入所有必需的模块。

import { HttpClientTestingModule } from '@angular/common/http/testing';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ReactiveFormsModule } from '@angular/forms';
import { MatDialogModule } from '@angular/material/dialog';
import { MatProgressBar, MatProgressBarModule } from '@angular/material/progress-bar';
import { MatSnackBarModule } from '@angular/material/snack-bar';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { RouterTestingModule } from '@angular/router/testing';
import { AppConfigService } from 'src/app/services/config/app-config.service';
import { SharedModule } from 'src/app/shared/shared.module';
import { MaterialModule } from 'src/material.module';
import { VesselManagementPopupComponent } from '../vessel-management/vessel-management-popup/vessel-management-popup.component';
import { PriceCardComponent } from './components/price-card/price-card.component';

import { RfqPageComponent } from './rfq-page.component';

fdescribe('RfqComponent', () => {
  let component: RfqPageComponent;
  let fixture: ComponentFixture<RfqPageComponent>;

  beforeEach(async () => {
    await TestBed.configureTestingModule({
      declarations: [RfqPageComponent ,PriceCardComponent, VesselManagementPopupComponent],
      imports: [RouterTestingModule,
                ReactiveFormsModule,
                MatSnackBarModule,
                MatDialogModule,
                HttpClientTestingModule,
                MaterialModule,
                BrowserAnimationsModule,
                
                SharedModule
                ],
                providers: [
                  {
                     provide: 
                     MatProgressBar,
                     AppConfigService,
                     useValue: {
                         getConfig: () => ({ 
                           baseUrl: 'dummy-url',
                           serviceBase: 'api-base'
                         })
                     }
                  }
               ],
    })
    .compileComponents();
  });

  beforeEach(() => {
    fixture = TestBed.createComponent(RfqPageComponent);
    component = fixture.componentInstance;
    fixture.detectChanges();
  });

  fit('should create', () => {
    expect(component).toBeTruthy();
  });

  it('should call method loadRipCodeErrorMsg', () => {
    component.loadRipCodeErrorMsg();
    expect(component).toBeTruthy();
  });

it is giving message as following but test cases are passed.它给出如下消息,但测试用例已通过。

ERROR: 'NG0303: Can't bind to 'max' since it isn't a known property of 'mat-progress-bar'.'

.html file .html 文件

<mat-progress-bar class="headder-mat-progress" mode="determinate" height="4px" [value]="loadingProgressValue"
            [max]="100">
        </mat-progress-bar>

You most likely need to add MatProgressBarModule to the imports array of TestBed.configureTestingModule({ .您很可能需要将MatProgressBarModule添加到imports TestBed.configureTestingModule({ .

Also, I have never used Angular Material and it seems on the latest version, there is no max input property (on the API tab here: https://material.angular.io/components/progress-bar/api ).另外,我从未使用过 Angular Material,在最新版本中似乎没有max输入属性(在此处的 API 选项卡上: https://material.angular.io/components/progress-bar/api )。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 NG0303:无法绑定到“matTreeNodeDefWhen”,因为它不是“mat-tree-node”的已知属性 - NG0303: Can't bind to 'matTreeNodeDefWhen' since it isn't a known property of 'mat-tree-node' NG0303:无法绑定到“ngIf”,因为它不是“div”的已知属性:Angular Modular Federation - NG0303: Can't bind to 'ngIf' since it isn't a known property of 'div' : Angular Modular Federation Angular11 - NG0303:无法绑定到“ngForOf”,因为它不是“tr”的已知属性 - Angular11 - NG0303: Can't bind to 'ngForOf' since it isn't a known property of 'tr' jasmine thorw 错误:'NG0303:无法绑定到'选项',因为它不是'div'的已知属性。' - jasmine thorw ERROR: 'NG0303: Can't bind to 'options' since it isn't a known property of 'div'.' NG0303:无法绑定到“ngbTooltip”,因为它不是“button”的已知属性 - NG0303: Can't bind to 'ngbTooltip' since it isn't a known property of 'button' 出现错误:NG0303:无法绑定到“ng-If”,因为它不是“app-grocery”的已知属性 - Getting Error: NG0303: Can't bind to 'ng-If' since it isn't a known property of 'app-grocery' NG0303:无法绑定到“ngif”,因为它不是“div”的已知属性 - NG0303: Can't bind to 'ngif' since it isn't a known property of 'div' NG0303:无法绑定到“ngIf”,因为它不是“[组件选择器]”的已知属性 - NG0303: Can't bind to 'ngIf' since it isn't a known property of '[component selector]' NG0303:无法绑定到“ngModel”,因为它不是“离子范围”的已知属性 - NG0303: Can't bind to 'ngModel' since it isn't a known property of 'ion-range' Angular - NgIf 无法在组件上工作:“NG0303:无法绑定到‘ngIf’,因为它不是‘p’的已知属性。” - Angular - NgIf not working on component: "NG0303: Can't bind to 'ngIf' since it isn't a known property of 'p'."
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM