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.

fixture.detectChanges() leads to unresolvable Problem in fakeAsync zone

See original GitHub issue

Angular Version: 12

“ngx-quill”: “^14.3.0”, “quill”: “^1.3.7”,

The problem is pretty easy to reproduce. Create a test component containing any quill instance.

Then if you do

beforeEach(() => {
  fixture.detectChanges()
})

everything works fine.

However if you do:

beforeEach(fakeAsync(() => {
  fixture.detectChanges();
});

it will always fail with a timer still in queue problem.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:12 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
activenodecommented, Dec 3, 2021

Unfortunately no. We did do a workaround but it’s pretty “over-engineered” IMO:

Apparently quill/ngx-quill needs fixture.detectChanges() to be ran outside of fakeAsync to ensure proper loading.

But that also triggers ngOnInit. Hence we do this:

// 1. catch the init call to avoid the actual call
const initSpy = spyOn(component, 'ngOnInit');

// 2. detectChanges for ngx-quill
fixture.detectChanges();

// 3. fall back again
initSpy.and.callThrough()
1reaction
KillerCodeMonkeycommented, Nov 25, 2021

Strange because I do not have any problems in my unit tests.

There are some with fakeasync as well.

Since this project is growing over years I forget some implementation details 😃.

I knew that there is an optional debounce timer for change detection in the editor.

Maybe this debouncing is running and you need to add a tick() with some milliseconds as Parameter.

David Lorenz @.***> schrieb am Do., 25. Nov. 2021, 08:50:

Unfortunately that does not help. We tried multiple different ways.

[image: image] https://user-images.githubusercontent.com/9058762/143400857-9db92093-4633-4d23-949f-8bbe28f4f536.png

Feel free to clone the above sample repo.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/KillerCodeMonkey/ngx-quill/issues/1425#issuecomment-978919006, or unsubscribe https://github.com/notifications/unsubscribe-auth/AARI4YDA2PFMQL4UII7XURLUNXTEXANCNFSM5IWSFAJQ .

Read more comments on GitHub >

github_iconTop Results From Across the Web

Does fixture.whenStable() actually do anything in my angular ...
detectChanges . My question is regarding what fixture.whenstable will do when inside of a FakeAsync execution zone as an Async zone should keep ......
Read more >
Unit test within async using fixture.detectChanges() fails #89
Hello,. This is the issue description: Using the method from ComponentFixture . detectChanges() is failing when you use it within an async() ...
Read more >
Testing Asynchronous Operations in Angular Components
Calling fixture.detectChanges() tells Angular to run change-detection. ... fakeAsync wraps your test function in the fakeAsync Zone.
Read more >
Testing - ts - GUIDE - Angular
But a direct, synchronous update of the component property is invisible. The test must call fixture.detectChanges() manually to trigger another cycle of change ......
Read more >
Testing - Angular
But a direct, synchronous update of the component property is invisible. The test must call fixture.detectChanges() manually to trigger another cycle of change ......
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