plotly / plotly/angular-plotly.js

Angular Plotly test TypeError: Cannot read properties of undefined (reading 'data')

Abierto
#257 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Lenguaje dominante
TypeScript
Estrellas
242
Forks
81
Merge medio
8 h 48 min
PR fusionados (30 d)
18

Descripción

i am having an issue running the tests file for my page

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:21)
    at PlotlyComponent.call [as ngOnDestroy] (http://localhost:9876/_karma_webpack_/webpack:/node_modules/angular-plotly.js/__ivy_ngcc__/fesm2015/angular-plotly.js.js:195:29)
    at executeOnDestroys (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2015/core.mjs:6537:32)
    at cleanUpView (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2015/core.mjs:6438:9)
    at destroyViewTree (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2015/core.mjs:6264:21)
    at destroyLView (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2015/core.mjs:6416:9)
    at RootViewRef.destroy (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2015/core.mjs:13512:9)
    at ComponentRef.destroy (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2015/core.mjs:13958:23)
    at ComponentFixture.destroy (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2015/testing.mjs:228:31)
    at UserContext.<anonymous> (http://localhost:9876/_karma_webpack_/webpack:/src/app/pages/graph.component.spec.ts:163:17)

i am using PlotlyViaWindowModule, when i start ng serve the plot is working correctly without any issues but i cant run the test


describe('GraphComponent', () => {
    let component: GraphComponent;
    let fixture: ComponentFixture<GraphComponent>;
    let debugElement: DebugElement;

    beforeEach(waitForAsync(() => {
        TestBed.configureTestingModule({
            declarations: [... , PlotlyComponent], providers: [...PlotlyService,                 { provide: MyPlotService, useClass: myPlotServiceMock},
],   imports: [
                ...
                PlotlyViaWindowModule,]

beforeEach(() => {
        fixture = TestBed.createComponent(GraphComponent);
        component = fixture.componentInstance;
        debugElement = fixture.debugElement;

    
        fixture.detectChanges();
    });

    it('shoud create the app', () => {
        expect(component).toBeTruthy();
    });

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza ejecutando el spec fallido de GraphComponent en src/app/pages/graph.component.spec.ts y revisa la configuración de PlotlyViaWindowModule. Rastrea la llamada a createFigure de PlotlyComponent durante ngOnDestroy, usando el stack trace informado como punto de entrada. Se considera terminado cuando el test se completa sin el TypeError mientras el componente sigue siendo utilizable con ng serve.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
angular, plotly, typescript
Área
frontend, testing
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.