Search code examples
angulartypescriptjasmineprimengquill

ReferenceError: Quill is not defined while unit testing


I got this same issue and i resolved it and working perfectly when i run the application.

But same issue am getting right now while run the unit test. am using karma and jasmine tool.

I have tried include quill.js file in karma.config.js fill as well.

  files: ['./node_modules/quill/quill.js',
          { pattern: './src/test.ts', watched: true }
        ],

but still am facing the same issue.

Any idea to resolve this issue?


Solution

  • I have resolved this issue by using a flag with *ngIf

    <div class="ui-grid-col-6" style="width:114%;" *ngIf="display">
                       <p-editor [(ngModel)]="printEmailCOC.MailBody" [style]="{'height':'250px'}"></p-editor>
                   </div>
    
    • I am assigning that flag to true while running that code via application
    • I am assigning set that flag to false while running that code via unit testing.

    So Now the p-editor DOM element does not render. And we don't care about the quill package while Unit Testing.