简体   繁体   中英

Cannot find module 'rxjs/testing' from 'jasmine-marbles.umd.js'

I am currently want to test my effects with ngrx/effects. I followed the markdown but I have an error when I want run my test.

Cannot find module 'rxjs/testing' from 'jasmine-marbles.umd.js'

Here is my code (For the moment I did not do expectations, I just want my test runs) :

import { TestBed } from '@angular/core/testing'
import { provideMockActions } from '@ngrx/effects/testing'
import { ReplaySubject } from 'rxjs/ReplaySubject'
import { hot, cold } from 'jasmine-marbles'
import { Observable } from 'rxjs/Observable'
import { VersionService } from '../../service/version/version.service'

import { DataEffects } from './data.effect'
import { RequestVersions, ReceiveVersions } from './data.action'

describe('My Effects', () => {
    let versionService: VersionService
    let effects: DataEffects
    let actions: Observable<any>

    beforeEach(() => {
        TestBed.configureTestingModule({
            imports: [
                // any modules needed
            ],
            providers: [
                DataEffects,
                provideMockActions(() => actions),
                {provide: VersionService, useValue: {
                    getVersions: jest.fn().mockReturnValueOnce({data: {versions: 'MOCKED_VERSION_RESULT'}})
                }}
            ],
        })
        versionService = TestBed.get(VersionService)
        effects = TestBed.get(DataEffects)
    })

    it('should work', () => {
        const action = new RequestVersions()
        const completion = new ReceiveVersions('MOCKED_VERSION_RESULT')

        actions = hot('--a-', { a: action });
        const expected = cold('--b', { b: completion })
    })
}

And here what my package.json look like :

  [...]
  "dependencies": {
    [... all @angular import ...]
    "@ngrx/effects": "^5.2.0",
    "@ngrx/store": "^5.2.0",
    "@ngrx/store-devtools": "^5.2.0",
    "bootstrap": "^4.0.0",
    "core-js": "^2.4.1",
    "rxjs": "^5.5.6",
    "zone.js": "^0.8.19"
  },
  "devDependencies": {
    "@angular/cli": "1.6.7",
    "@angular/compiler-cli": "^5.2.0",
    "@angular/language-service": "^5.2.0",
    "@types/jest": "^22.1.4",
    "@types/node": "~6.0.60",
    "codelyzer": "^4.0.1",
    "jasmine-marbles": "^0.3.0",
    "jest": "^22.4.2",
    "jest-junit": "^3.6.0",
    "jest-preset-angular": "^5.2.0",
    "ts-node": "~4.1.0",
    "tslint": "~5.9.1",
    "typescript": "~2.5.3"
  }
  [...]

Can anyone help me in this matter ?

Just ran into this as well.

In my case using jasmine-marbles@v0.2.0 instead of the @latest resolve it, since it doesn't seem to require the peer dependency of the beta rxjs 6 release

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM