无法从 'jasmine-marbles.umd.js' 中找到模块 'rxjs/testing'
Cannot find module 'rxjs/testing' from 'jasmine-marbles.umd.js'
我目前想用 ngrx/effects 测试我的效果。我遵循了降价,但是当我想要 运行 我的测试时出现错误。
Cannot find module 'rxjs/testing' from 'jasmine-marbles.umd.js'
这是我的代码(目前我没有做期望,我只是想要我的测试运行s):
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 })
})
}
这是我的 package.json 的样子:
[...]
"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"
}
[...]
谁能帮我解决这个问题?
只需 运行 加入此内容。
在我的例子中,使用 jasmine-marbles@v0.2.0 而不是 @latest 来解决它,因为它似乎不需要 beta rxjs 6 版本的对等依赖性
我目前想用 ngrx/effects 测试我的效果。我遵循了降价,但是当我想要 运行 我的测试时出现错误。
Cannot find module 'rxjs/testing' from 'jasmine-marbles.umd.js'
这是我的代码(目前我没有做期望,我只是想要我的测试运行s):
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 })
})
}
这是我的 package.json 的样子:
[...]
"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"
}
[...]
谁能帮我解决这个问题?
只需 运行 加入此内容。
在我的例子中,使用 jasmine-marbles@v0.2.0 而不是 @latest 来解决它,因为它似乎不需要 beta rxjs 6 版本的对等依赖性