Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when using change detection in component tests (jest) #385

Open
homj opened this issue Mar 16, 2023 · 3 comments
Open

Error when using change detection in component tests (jest) #385

homj opened this issue Mar 16, 2023 · 3 comments

Comments

@homj
Copy link

homj commented Mar 16, 2023

Problem

The NgxEchartsDirective is not properly handling being destroyed when used in component tests in combination with explicit change detection calls

Observed behavior

When testing the usage of the echarts directive within a parent component and triggering change detection via fixture.detectChanges(), jest reports an error:

Error: 1 component threw errors during cleanup

Expected behavior

The directive should be destroyed without causing errors

Potential causes

I assume this is due to the use of ChangeFilter and subscriptions in ngOnChanges that are not being unsubscribed in ngOnDestroy

Technologies & Versions:

Angular: 15.0.1
ngx-echarts: 15.0.1
jest: 28.1.1

@xieziyu
Copy link
Owner

xieziyu commented Mar 16, 2023

Thanks for your feedback. I will look into this issue. If you could provide your test specs, it would be very helpful.

@homj
Copy link
Author

homj commented Mar 16, 2023

@xieziyu
Copy link
Owner

xieziyu commented Mar 20, 2023

Hi @homj ,
Please try to upgrade ngx-echarts@v15.0.2. The ChangeFilter subscriptions are unsubscribed now. But I'm not sure if it solves this issue, as I didn't reproduce this error using the spec in gist. Looking forward to your reply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants