Невозможно запустить простейшие тесты rxjs-marbles

При полностью новой установке ng new myapp (cli версии 1.6.8, Angular 5.2.0, rxjs 5.5.6) я установил rxjs marbles.

У меня проблемы с запуском самого простого теста по некоторым причинам конфигурации. Кто-нибудь может сказать мне, что пошло не так?

import { TestBed, async } from '@angular/core/testing';
import { marbles } from 'rxjs-marbles/jasmine';
import { map } from 'rxjs/operators';
import { AppComponent } from './app.component';

describe('AppComponent', () => {
  beforeEach(async(() => {
    TestBed.configureTestingModule({
      declarations: [
        AppComponent,
      ],
    }).compileComponents();
  }));

  it('should see mapped values', marbles(m => {
    const values = { a: 1, b: 2, c: 3, x: 2, y: 4, z: 6 };

    const source = m.cold('--a---b---c-|', values);
    const expected = m.cold('--x---y---z-|', values);
    const result = source.pipe(map(x => x * 2));
    m.expect(result).toBeObservable(expected);
  }));
});

Ошибки консоли:

ERROR in ./node_modules/rxjs-marbles/esm5/marbles.js
Module not found: Error: Can't resolve 'rxjs/testing' in '/Users/armo/Code/rxjsmarbles/node_modules/rxjs-marbles/esm5'
 @ ./node_modules/rxjs-marbles/esm5/marbles.js 9:0-45
 @ ./node_modules/rxjs-marbles/esm5/jasmine/index.js
 @ ./src/app/app.component.spec.ts
 @ ./src \.spec\.ts$
 @ ./src/test.ts

ERROR in ./node_modules/rxjs-marbles/esm5/context-deprecated.js
Module not found: Error: Can't resolve 'rxjs/testing' in '/Users/armo/Code/rxjsmarbles/node_modules/rxjs-marbles/esm5'
 @ ./node_modules/rxjs-marbles/esm5/context-deprecated.js 10:0-45
 @ ./node_modules/rxjs-marbles/esm5/marbles.js
 @ ./node_modules/rxjs-marbles/esm5/jasmine/index.js
 @ ./src/app/app.component.spec.ts
 @ ./src \.spec\.ts$
 @ ./src/test.ts

ERROR in ./node_modules/rxjs-marbles/esm5/context-run.js
Module not found: Error: Can't resolve 'rxjs/testing' in '/Users/armo/Code/rxjsmarbles/node_modules/rxjs-marbles/esm5'
 @ ./node_modules/rxjs-marbles/esm5/context-run.js 1:0-45
 @ ./node_modules/rxjs-marbles/esm5/marbles.js
 @ ./node_modules/rxjs-marbles/esm5/jasmine/index.js
 @ ./src/app/app.component.spec.ts
 @ ./src \.spec\.ts$
 @ ./src/test.ts
ERROR in node_modules/rxjs-marbles/context.d.ts(1,22): error TS2305: Module '"/Users/armo/Code/rxjsmarbles/node_modules/rxjs/Rx"' has no exported member 'SchedulerLike'.
node_modules/rxjs-marbles/context.d.ts(2,31): error TS2307: Cannot find module 'rxjs/testing'.
node_modules/rxjs-marbles/types.d.ts(2,31): error TS2307: Cannot find module 'rxjs/testing'.

person user776686    schedule 20.08.2018    source источник


Ответы (1)


rxjs-marbles версии 3 и выше зависят от RxJS версия 6.

Если вы используете RxJS версии 5, вам нужно будет использовать rxjs-marbles версию 2, последняя версия которой - 2.4.1.

И если вы используете эту версию, для документации вам следует обратиться к README в ветке этой версии, а не README в master.

person cartant    schedule 20.08.2018