我正在使用 ngx-quill 和 image-resize-module 并让它在我的应用程序中工作
import Quill from 'quill';
import ImageResize from 'quill-image-resize-module';
Quill.register('modules/imageResize', ImageResize);
export class MyComponent {
quillModules = {
imageResize: {},
toolbar: [
...
],
};
}
在我的 angular.json 中,我在构建和测试的脚本中添加了 quill.js
"scripts": [
"node_modules/quill/dist/quill.min.js",
]
我的测试文件正在导入 QuillModule
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
QuillModule,
...
],
但是,在我的茉莉花测试中,我收到了这个警告
'quill', '用'覆盖模块/imageResize', 函数 t(e){ ... }
这个错误
{
"message": "An error was thrown in afterAll\n[object ErrorEvent]",
"str": "An error was thrown in afterAll\n[object ErrorEvent]"
}
这打破了我的整个测试运行器,它在抛出这个错误之前只运行了大约 40 个测试。我将其缩小到在我的组件中注册 imageResize 模块
Quill.register('modules/imageResize', ImageResize);
如果我删除此行,我的测试将再次运行。
编辑
我找到了修复并添加了答案