Skip to content

debounceTime does not emit with jasmine.clock.tick in v7 #6382

Closed
@dpurp

Description

@dpurp

Bug Report

\cc @leggechr

Current Behavior
In v7, debounceTime does not emit any values when installing the jasmine clock and using tick. (This works in v6)

Expected behavior
rxjs is compatible with jasmine.clock, or there is a documented workaround.

Reproduction
Note the reproductions below contain examples using the jasmine clock (which fails in v7) and the native clock (which succeeds).

v7: https://stackblitz.com/edit/rxjs-v7-debouncetime?file=test.ts
v6: https://stackblitz.com/edit/rxjs-v6-debouncetime?file=test.ts

describe('failing time tests with jasmine clock', () => {
  beforeEach(() => {
    jasmine.clock().install();
  });

  afterEach(() => {
    jasmine.clock().uninstall();
  });

  it('debounces time', async () => {
    const duration = 10;
    const source = new Subject<string>();
    const debouncedSource$ = source.pipe(
      debounceTime(duration),
      shareReplay(1)
    );
    debouncedSource$.subscribe();

    source.next('should not be emitted');
    source.next('expected value');
    jasmine.clock().tick(duration + 1); // Wait for debounce to happen.

    expect(await firstValueFrom(debouncedSource$)).toEqual('expected value');
  });
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    7.xIssues and PRs for version 7.x

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions