使用本地库模块时测试失败

时间:2019-10-22 06:03:42

标签: angular angular8 angular-test

当我进行以下错误测试时,我正在使用带有组件(项目)的本地库:

1. If 'lib-ibo-library' is an Angular component, then verify that it is part of this module.
        'lib-ibo-library' is not a known element:
        1. If 'lib-ibo-library' is an Angular component, then verify that it is part of this module.
        2. If 'lib-ibo-library' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message. ("[ERROR ->]<lib-ibo-library></lib-ibo-library>"): ng:///DynamicTestModule/AppComponent.html@0:0

这是我的module.ts文件:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { IboLibraryModule } from 'ibo-library';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';

@NgModule({
    declarations: [
        AppComponent
    ],
    imports: [
        BrowserModule,
        AppRoutingModule,
        IboLibraryModule
    ],
    providers: [],
    bootstrap: [AppComponent]
})
export class AppModule { }

我的组件html文件:

<lib-ibo-library></lib-ibo-library>

该如何解决?是否需要在父应用程序中添加?

我的ibo库模块文件:

import { NgModule } from '@angular/core';
import { IboLibraryComponent } from './ibo-library.component';



@NgModule({
  declarations: [IboLibraryComponent],
  imports: [
  ],
  exports: [IboLibraryComponent]
})
export class IboLibraryModule { }

组件ts文件:

import { Component, OnInit } from '@angular/core';

@Component({
    selector: 'lib-ibo-library',
    templateUrl: './ibo-library.component.html',
    styleUrls: ['./ibo-library.component.scss']
})
export class IboLibraryComponent implements OnInit {

    constructor() { }

    ngOnInit() {}

}

0 个答案:

没有答案