首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法运行最简单的rxjs-marble测试

无法运行最简单的rxjs-marble测试
EN

Stack Overflow用户
提问于 2018-08-20 16:26:11
回答 1查看 305关注 0票数 1

在全新安装的ng new myapp (cli版本1.6.8,Angular 5.2.0,rxjs 5.5.6)上,我安装了rxjs marble。

由于一些配置原因,我在运行非常基本的测试时遇到了问题。谁能告诉我哪里出了问题?

代码语言:javascript
复制
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);
  }));
});

控制台错误:

代码语言:javascript
复制
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'.
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-08-20 16:34:24

rxjs-marbles versions 3 and later depend upon RxJS version 6.

如果您使用的是RxJS版本5,则需要使用最新版本为2.4.1rxjs-marbles版本2。

如果您使用该版本的文档,则应该参考README in that version's branch,而不是master中的自述文件。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51926745

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档