SimonTestNet / SimonTest

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

Cannot read property 'elements' of undefined #30

Closed mahidaturgana closed 5 years ago

mahidaturgana commented 5 years ago

Spinning up a new test scenario with CLI, including lodash-es, and using the following AppComponent will generate the error "Cannot read property 'elements' of undefined"

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

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
export class AppComponent implements OnInit {
  title = 'testing';
  constructor(private _changeDetectorRef: ChangeDetectorRef) {
    console.log('ctor');
  }
  public ngOnInit() {
    console.log('ngOnInit');
  }
}
ManuelDeLeon commented 5 years ago

Thanks for reporting it. Please update to v1.4.2 and let me know if you have any issues.

mahidaturgana commented 5 years ago

Error is still present while using v1.4.2 - Tested against my full solution and against a fresh CLI created project as described above.

Further investigation: If either the lodash-es/filter import or the ChangeDetectorRef are removed, there is no error and the spec file generates appropriately.

ManuelDeLeon commented 5 years ago

Please post a piece of code to repro the issue, like you did before. Your original code now works with v1.4.2 so I need a new file to test with. Thanks.

mahidaturgana commented 5 years ago

For the isolated scenario above, seems I spoke too soon, that is fixed. Perhaps VSCode didn't take the changes properly.

That said, in my full solution I am still running into the same error. I've almost got it isolated to a simple reproduction case. Would you like a new issue filed or continue in the comments here?

ManuelDeLeon commented 5 years ago

Here is fine =)

mahidaturgana commented 5 years ago
import { Component, ChangeDetectorRef, OnInit } from '@angular/core';
import filter from 'lodash-es/filter';

export enum Types {
  TypeA = 1,
  TypeB = 2,
  TypeC = 3,
}

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})
export class AppComponent implements OnInit {
  public TempTypes = Types;
  title = 'testing';

  constructor() {
    console.log('ctor');
  }
  public ngOnInit() {
    console.log('ngOnInit');
  }
}

Added: enum Removed: ChangeDetectorRef

Again, if the lodash-es/filter import is removed, everything works.

ManuelDeLeon commented 5 years ago

Should be solved in v1.4.3 Let me know how it goes.

mahidaturgana commented 5 years ago

@ManuelDeLeon - Looks good. Thanks for the quick turnaround.