SimonTestNet / SimonTest

Repository for SimonTest questions and issues https://simontest.net
16 stars 2 forks source link

Cannot read property 'elements' of undefined #32

Closed mahidaturgana closed 5 years ago

mahidaturgana commented 5 years ago

Just like what I reported on #30 but under slightly different circumstances, here is the app.component.ts:

import { Component, OnDestroy } from '@angular/core';
import filter from 'lodash-es/filter';

export declare abstract class Base implements OnDestroy {
  ngOnDestroy(): void;
}

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
export class AppComponent extends Base implements OnDestroy {

  constructor() {
    super()
  }

  public ngOnDestroy() {
    console.log('ngOnDestroy');
    super.ngOnDestroy();
  }
}
ManuelDeLeon commented 5 years ago

Sorry for the late reply. I can generate a test scaffold from that code without errors. Are you using v1.5.1 or above?

Here's the output I get:

import { ComponentFixture, TestBed } from "@angular/core/testing";
import { NO_ERRORS_SCHEMA } from "@angular/core";
import { AppComponent } from "./boot.browser";
describe("AppComponent", () => {
    let component: AppComponent;
    let fixture: ComponentFixture<AppComponent>;
    beforeEach(() => {
        TestBed.configureTestingModule({
            schemas: [NO_ERRORS_SCHEMA],
            declarations: [AppComponent]
        });
        fixture = TestBed.createComponent(AppComponent);
        component = fixture.componentInstance;
    });
    it("can load instance", () => {
        expect(component).toBeTruthy();
    });
});
mahidaturgana commented 5 years ago

Oddly enough I had an unused import line which I removed before posting. That along with everything else seems to be the culprit.

ManuelDeLeon commented 5 years ago

Ah, pick up v1.5.2 and let me know how it goes.

Thanks