Skip to content

Angular 13: Errors when running Unit Tests #198

Closed
@aarontoys

Description

@aarontoys

I get serval errors when running units tests after upgrading to Angular 13.

stacktrace: TypeError: Cannot read properties of undefined (reading 'data')
TypeError: Cannot read properties of undefined (reading 'data')
    at PlotlyComponent.createFigure (http://localhost:9876/_karma_webpack_/webpack:/node_modules/angular-plotly.js/__ivy_ngcc__/fesm2015/angular-plotly.js.js:285:1)
    at PlotlyComponent.ngOnDestroy (http://localhost:9876/_karma_webpack_/webpack:/node_modules/angular-plotly.js/__ivy_ngcc__/fesm2015/angular-plotly.js.js:195:1)
    at executeOnDestroys (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2015/core.mjs:7368:1)
    at cleanUpView (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2015/core.mjs:7271:1)
    at destroyViewTree (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2015/core.mjs:7097:1)
    at destroyLView (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2015/core.mjs:7249:1)
    at RootViewRef.destroy (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2015/core.mjs:21290:1)
    at ComponentRef.destroy (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2015/core.mjs:21696:1)
    at ComponentFixture.destroy (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2015/testing.mjs:227:1)
    at http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2015/testing.mjs:1830:1}
Error: 1 component threw errors during cleanup
    at TestBedRender3.destroyActiveFixtures (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2015/testing.mjs:1842:1)
    at TestBedRender3.resetTestingModule (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2015/testing.mjs:1677:1)
    at Function.resetTestingModule (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2015/testing.mjs:1620:1)
    at UserContext.<anonymous> (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2015/testing.mjs:2006:1)
    at _ZoneDelegate.invoke (http://localhost:9876/_karma_webpack_/webpack:/node_modules/zone.js/dist/zone.js:409:1)
    at ProxyZoneSpec.onInvoke (http://localhost:9876/_karma_webpack_/webpack:/node_modules/zone.js/dist/zone-testing.js:303:43)
    at _ZoneDelegate.push.67809._ZoneDelegate.invoke (http://localhost:9876/_karma_webpack_/webpack:/node_modules/zone.js/dist/zone.js:408:1)
    at Zone.run (http://localhost:9876/_karma_webpack_/webpack:/node_modules/zone.js/dist/zone.js:169:1)
    at runInTestZone (http://localhost:9876/_karma_webpack_/webpack:/node_modules/zone.js/dist/zone-testing.js:599:38)
    at UserContext.<anonymous> (http://localhost:9876/_karma_webpack_/webpack:/node_modules/zone.js/dist/zone-testing.js:614:24)
zone.js:218 Uncaught Error: Uncaught (in promise): Error: Resize must be passed a displayed plot div element.
Error: Resize must be passed a displayed plot div element.
...
(full stack trace can be found in reproduction repo). 

This repo can produce the error.

Thanks in advance for your help resolving this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions