Ripple effect on button causes fakeAsync component tests to fail
Bug, feature request, or proposal:
Bug: Ripple effect on button causes fakeAsync component test to fail with the message: " Error: 1 timer(s) still in the queue."
What is the expected behavior?
The test to pass without any error.
What is the current behavior?
The test fail with the following message:
Error: 1 timer(s) still in the queue.
at new Error (native)
at webpack:///app/~/@angular/core/bundles/core-testing.umd.js:353:0 <- src/test.ts:6646:27 [ProxyZone]
at TestBed.execute (webpack:///app/~/@angular/core/bundles/core-testing.umd.js:820:0 <- src/test.ts:7113:23) [ProxyZone]
at Object.
What are the steps to reproduce?
FooComponent template with button i.e. <button md-raised-button>Foo</button>
And component test:
`beforeEach(async(() => {
fixture = TestBed.createComponent(FooComponent);
}
fit('test failing', fakeAsync(() => {
fixture.debugElement.query(By.css('button')).nativeElement.click();
fixture.detectChanges();
tick();
}));
The test succeeds when adding disableRipple to the button.
What is the use-case or motivation for changing an existing behavior?
Hard to write component tests in 2.0.0-alpha.11-2.
Which versions of Angular, Material, OS, browsers are affected?
Introduced in 2.0.0-alpha.11-2, was working in 2.0.0-alpha.10. Using angular 2.2.4.
Is there anything else we should know?
@crisbeto can you reproduce this?
The same test works for me @Uniqen. Are you sure there isn't something else that is triggering a timeout? Here's my full setup:
import {Component} from '@angular/core';
import {async, TestBed, ComponentFixture, fakeAsync, tick} from '@angular/core/testing';
import {By} from '@angular/platform-browser';
fdescribe('foo', () => {
let fixture: ComponentFixture<FooComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [FooComponent]
});
TestBed.compileComponents();
fixture = TestBed.createComponent(FooComponent);
}));
it('test failing', fakeAsync(() => {
fixture.debugElement.query(By.css('button')).nativeElement.click();
fixture.detectChanges();
tick();
}));
});
@Component({ template: '<button md-raised-button>Foo</button>' })
export class FooComponent {}
When I add fixture.detectChanges(); before the click I get the "Error: 1 timer(s) still in the queue." error.
Weird since I don't get it. Neither when adding it inside the test itself, nor when I put it in the beforeEach.
I've located the difference in our tests:
imports: [
MaterialModule.forRoot(),
]
In my test the before each is:
TestBed.configureTestingModule({
declarations: [FooComponent],
imports: [
MaterialModule.forRoot(),
]
}).compileComponents();
Isn't that required to include Material directives in the test?
You're probably right, I'll re-check it.
AFAICT this is no longer an issue
import {Component} from '@angular/core';
import {async, TestBed, ComponentFixture, fakeAsync, tick} from '@angular/core/testing';
import {By} from '@angular/platform-browser';
import {MdButtonModule} from '@angular/material';
fdescribe('foo', () => {
let fixture: ComponentFixture<FooComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [FooComponent],
imports: [
MdButtonModule
]
});
TestBed.compileComponents();
fixture = TestBed.createComponent(FooComponent);
}));
it('test failing', fakeAsync(() => {
fixture.debugElement.query(By.css('button')).nativeElement.click();
fixture.detectChanges();
tick();
}));
});
@Component({ template: '<button md-raised-button>Foo</button>' })
export class FooComponent {}
Okay, thanks!
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.