Ramesh Rajendran
Ramesh Rajendran

Reputation: 38683

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?

Upvotes: 2

Views: 3335

Answers (2)

Janatbek
Janatbek

Reputation: 465

I added "node_modules/quill/dist/quill.js" in angular.json file in scripts array "test": { "builder": "@angular-devkit/build-angular:karma", "options": { "main": "src/test.ts", "karmaConfig": "src/karma.conf.js", "polyfills": "src/polyfills.ts", "tsConfig": "src/tsconfig.spec.json", "scripts": [ "node_modules/quill/dist/quill.js" ], "styles": [ "src/scss/styles.scss" ], "assets": [ "src/assets", "src/favicon.ico" ] } }, restarted ng test and the component passed the test

Upvotes: 2

Ramesh Rajendran
Ramesh Rajendran

Reputation: 38683

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.

Upvotes: 1

Related Questions