gpt4 book ai didi

rxjs - 无法从 'rxjs/testing' 找到模块 'jasmine-marbles.umd.js'

转载 作者:行者123 更新时间:2023-12-02 11:21:35 29 4
gpt4 key购买 nike

我目前想用 ngrx/effects 测试我的效果。我遵循了 Markdown ,但当我想运行测试时出现错误。

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

这是我的代码(目前我没有做期望,我只想运行我的测试):

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 版本的对等依赖

关于rxjs - 无法从 'rxjs/testing' 找到模块 'jasmine-marbles.umd.js',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49530947/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com