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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

debugElement.properties with ivy differ from debugElement.properties without ivy #33695

Closed
nmatushevskiy opened this issue Nov 8, 2019 · 2 comments

Comments

@nmatushevskiy
Copy link

@nmatushevskiy nmatushevskiy commented Nov 8, 2019

馃悶 bug report

Affected Package

The issue is caused by package angular/core

Is this a regression?

Yes, the previous version in which this bug was not present was: 9.0.0-rc.1 without ivy.

Description

In unit test i have <input type="radio" /> and want to get some property (in my case, it's "checked") by debugElement.properties. Without ivy this code works fine:

The component:

@Component({
  selector: 'app-root',
  template: `<input type="radio" value="one" [(ngModel)]="active"/>`
})
export class AppComponent {
  active = 'one';
}

The unit test:

it('issue example', () => {
    console.log('debugElement properties', debugElement.query(By.css('input[type="radio"]')).properties);
    console.log('debugElement properties checked', debugElement.query(By.css('input[type="radio"]')).properties.checked);
    console.log('nativeElement checked', debugElement.query(By.css('input[type="radio"]')).nativeElement.checked);

    expect(debugElement.query(By.css('input[type="radio"]')).properties.checked).toBeDefined();
    expect(debugElement.query(By.css('input[type="radio"]')).properties.checked).toBe(true);

    expect(debugElement.query(By.css('input[type="radio"]')).nativeElement.checked).toBe(true);
  });

logs:
小薪懈屑芯泻 褝泻褉邪薪邪 2019-11-08 胁 18 20 09

If ivy enable, same code will be work differently.
logs:
小薪懈屑芯泻 褝泻褉邪薪邪 2019-11-08 胁 18 19 32

the first two tests fail.

馃敩 Minimal Reproduction

github: https://github.com/nmatushevskiy/ivy-debug-element-properties-issue

  • clone repository
  • npm i
  • ng test

unit test with issue you can find in: https://github.com/nmatushevskiy/ivy-debug-element-properties-issue/blob/master/src/app/app.component.spec.ts

馃實 Your Environment

Angular CLI: 9.0.0-rc.1
Node: 10.16.0
OS: darwin x64
Angular: 9.0.0-rc.1
... animations, cli, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.900.0-rc.1
@angular-devkit/build-angular     0.900.0-rc.1
@angular-devkit/build-optimizer   0.900.0-rc.1
@angular-devkit/build-webpack     0.900.0-rc.1
@angular-devkit/core              9.0.0-rc.1
@angular-devkit/schematics        9.0.0-rc.1
@ngtools/webpack                  9.0.0-rc.1
@schematics/angular               9.0.0-rc.1
@schematics/update                0.900.0-rc.1
rxjs                              6.3.3
typescript                        3.6.4
webpack                           4.41.2

@pkozlowski-opensource

This comment has been minimized.

Copy link
Member

@pkozlowski-opensource pkozlowski-opensource commented Nov 8, 2019

Hmmmmm, I don't see the FormsModule being imported in your test (I guess the checked property is set by ngModel). I find it surprising that it used to with VE...

@nmatushevskiy

This comment has been minimized.

Copy link
Author

@nmatushevskiy nmatushevskiy commented Nov 11, 2019

FormsModule imported into AppModule, which imported in my test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can鈥檛 perform that action at this time.