Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

fakeAsync test fails when testing code using rxjs 5 rxjs/scheduler/asap #1061

@DarthRainbows

Description

@DarthRainbows

fakeAsync tests throw the error "Unknown macroTask scheduled in fake async test: setImmediate" when the code under test uses the rxjs Asap Scheduler.

Steps to reproduce:

  1. Write function using Asap Scheduler
import { asap } from 'rxjs/scheduler/asap';

export class TestClass {
  complete = false;
  doSomethingAsap() {
    asap.schedule(() => {
      this.complete = true;
    });
  }
}
  1. Write unit test against the function
import { fakeAsync, tick } from '@angular/core/testing';
import { TestClass } from './test-class';

describe('TestClass', () => {
  it('should do stuff asynchronously', fakeAsync(() => {
    // arrange
    const test = new TestClass();

    // act
    test.doSomethingAsap();

    tick();

    // assert
    expect(test.complete).toBeTruthy();
  }));
});

Expected results: test passes
Actual results: test throws "Unknown macroTask scheduled in fake async test: setImmediate"

Found using Angular 5.2.9 and Zone.js 0.8.20

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions