question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unit Testing with Jest & Angular 10: "Uncaught (in promise): Error: Not supported"

See original GitHub issue

I cannot unit test a component that uses Quill as I am getting this error:

Uncaught (in promise): Error: Not supported Error: Not supported at QuillService.<anonymous> (projects/ngx-quill/src/lib/quill.service.ts:25:29)

I am configuring Quill like this in my spec.ts file:

import { QuillModule } from 'ngx-quill';
...
beforeEach(async(() => {
    TestBed.configureTestingModule({
      declarations: [ ... ],
      imports: [ ... ],
      providers: [QuillModule.forRoot().providers],
      schemas: [CUSTOM_ELEMENTS_SCHEMA]
    })
    .compileComponents();
    fixture = TestBed.createComponent(...);
    component = fixture.componentInstance;
    fixture.detectChanges();
 }));

I am not testing Quill elements; at this point, even a dummy test does not pass because of this error. If I comment out the fixture.detectChanges() line above, the test passes correctly.

Thank you for any suggestions!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
KillerCodeMonkeycommented, Jan 21, 2021

yes it looks fine.

i think maybe it has something todo with your jest config.

maybe you could identify the real cause. i would guess that jest can not handle the async import in the service.

1reaction
KillerCodeMonkeycommented, Jan 21, 2021

sounds like a missing polyfill for promises?

which version of angular and ngx-quill do you use?

my unit tests are running without any problem

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular + Jest: Error: Uncaught (in promise): Failed to load C ...
Unfortunately, I can't get Jest to work. I want to use it to build unit tests for my Angular webapp. I just noticed...
Read more >
Async in unit tests does not handle unresolved promises #20827
This test should fail, but because the promise is never resolved and the test does not wait for it to be resolved it...
Read more >
Testing services - Angular
Here are some synchronous and asynchronous unit tests of the ValueService written without assistance from Angular testing utilities. app/demo/demo.spec.ts
Read more >
Successfully Throwing Async Errors with the Jest Testing Library
Below is a very, very simplified version of the React component I needed to unit test with Jest. I'll break down what its...
Read more >
Mocha - the fun, simple, flexible JavaScript test framework
simple, flexible, fun. Mocha is a feature-rich JavaScript test framework running on Node.js and in the browser, making asynchronous testing simple and fun....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found