Identify all tests that have not been updated to proper imports and “run mode”

Just a list, not the fixes.

The work here is simple: Create a list or spreadsheet we can edit that tracks all of the tests in our suite that need to be updated in two different ways:

  1. Imports need to be “modernized”
  2. TestScheduler usage needs to be using “run mode”.

Identify tests without “modernized” imports

A lot of work was already done here, but there’s still some work that needs to be done. Basically, we need to update tests to make sure they are all importing from rxjs, rxjs/operators, rxjs/testing, etc, and NOT importing like import * as Rx from 'rxjs'.

We also need to make sure all operator usage is “pipeable”. There are still a few tests where they’re being “dot-chained” which isn’t what we want.

Identify tests that need to use “run mode”

Run mode is testing with TestScheduler.prototype.run like so:

let testScheduler: TestScheduler;

beforeEach(() => {
  // "defaultObservableComparar" isn't a real thing, I forgot what it's called :P haha.
  testScheduler = new TestScheduler(defaultObservableComparer); 
});

it('should be a test like this', () => {
  testScheduler.run(({ hot, cold, expectObservable }) => {
     const source = hot('---a--b--c--d--|');
     const subs = '     -----^----------!';
     const expected = '      --b--c--d--|';
     expect(source, subs).toBe(expected);
  });
});

Expected result

A list we can use to track progress on updating these files.

Impact

It will drive a LOT of work for people, particularly people new to contributing to the code base. This work will enable us to more cleanly move to RxJS v 7 and beyond!

Moving to using “run mode” will enable us to use a code formatter (such as Prettier or Clang format) on the library, because we won’t have to worry about jacking up marble diagrams anymore (because we can use spaces in the strings more effectively). This will help others contribute to the codebase by making it more readable.

2 thoughts on “Identify all tests that have not been updated to proper imports and “run mode”

  1. I’ve created a list of all (I hope) NOT “modernized” imports.
    Here it’s.

    NOT “modernized” imports

    Spec Root folder

    • exports-spec.ts link
    • Notification-spec.ts link
    • Observable-spec.ts link
    • root-module-spec.ts link
    • Subject-spec.ts link
    • Subscription-spec.ts link

    Spec dtslint

    • partition-spec.ts link

    Spec Helpers

    • test-helper.ts link
    • testScheduler-ui.ts link

    Spec Observables

    • IteratorObservable-spec.ts link

    Spec Operators

    • defaultIfEmpty-spec.ts link
    • forkJoin-spec.ts link
    • let-spec.ts link
    • partition-spec.ts link

    Spec Subjects

    • AsyncSubject-spec.ts link
    • BehaviorSubject-spec.ts link
    • ReplaySubject-spec.ts link

    Spec Util

    • subscribeToResult-spec.ts link
    • UnsubscriptionError-spec.ts link
  2. Here a list of not pipeable operators which I have manage to find. (Hopely there are full list)
    Some files are not included because they are have been listed on previous list (Not modernized imports).

    NOT pipeable

    Spec Root Folder

    • Observable-spec.ts link (map, multicast, refCount, filter, count)
    • Subject-spec.ts link (L417) (.delay)

    Spec Operators

    • switch-spec.ts link (L35)
    • concatMap-spec.ts link (L18, L562 L591 L603 L615 L631 L646 L662 L677 .concatMap was called)
    • expand-spec.ts link (L22 L35)
    • let-spec.ts link (L10)
    • partition-spec.ts link (L244)
    • switch-spec.ts link (L35 L92 L313) Somewhere using Observable.of;
    • defaultIfEmpty-spec.ts link (L72 L74)
    • publish-spec.ts link (L45 L47 L49)
    • windowToggle-spec.ts link (L193 L195)
    • mergeScan-spec.ts link (.delay)
    • last-spec.ts link (L131)(.last)
    • publish-spec.ts link (L138) (.publish, .refCount)
    • share-spec.ts link (L246)(.repeat, .retry)
    • toPromise-spec.ts link (.toPromise)

    Spec Observables

    • from-spec.ts link (L23)
    • concat-spec.ts link (L61)
    • interval-spec.ts link (.take)
    • generate-spec.ts link (.take)
    • merge-spec.ts link (L252) (.delay)

    Spec Subjects

    • BehaviorSubject-spec.ts link
    • ReplaySubject-spec.ts link

    Spec Util

    • isPromise-spec.ts link (.toPromise)