如何在 angular 中使用 jest mock 来模拟导入依赖项(ckeditor)
How to mock import dependency(ckeditor) with jest mock in angular
我需要在我的测试中导入 CKEditorModule(如果我直接导入它只是无法解析),我如何使用 jest.mock 模拟它?
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { myComponent } from './myComponent';
import { FormsModule } from '@angular/forms';
describe('myComponent', () => {
let component: myComponent;
let fixture: ComponentFixture<myComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [myComponent],
imports: [FormsModule]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(myComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
好的。用 NO_ERRORS_SCHEMA
忽略它
我需要在我的测试中导入 CKEditorModule(如果我直接导入它只是无法解析),我如何使用 jest.mock 模拟它?
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { myComponent } from './myComponent';
import { FormsModule } from '@angular/forms';
describe('myComponent', () => {
let component: myComponent;
let fixture: ComponentFixture<myComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [myComponent],
imports: [FormsModule]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(myComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});
好的。用 NO_ERRORS_SCHEMA
忽略它