Skip to content

[Bug]async test will report error when call setTimeout with async beforeEach #22448

@JiaLiPassion

Description

@JiaLiPassion

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

call timeout

beforeEach(async(() => {
  TestBed.configureTestingModule({
      declarations: [
        AppComponent
      ],
    }).compileComponents();
}));
it('simple timeout', async(() => {
    setTimeout(() => {
      expect(true).toBe(true);
    }, 200);
  }));

This case will throw Error: 'expect' was used when there was no current spec error.

Expected behavior

No error throw.

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

Environment


Angular version: 5.2.6


Browser:
- [x] Chrome (desktop) version XX
- [ ] Chrome (Android) version XX
- [ ] Chrome (iOS) version XX
- [ ] Firefox version XX
- [ ] Safari (desktop) version XX
- [ ] Safari (iOS) version XX
- [ ] IE version XX
- [ ] Edge version XX
 
For Tooling issues:
- Node version: XX  
- Platform:  

Others:

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: testingIssues related to Angular testing features, such as TestBed

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions