根据rxjs 弹珠文档,同步分组的当前行为如下:
'(ab)-(cd)': on frame 0, emits a and b then on frame 50, emits c and d
Run Code Online (Sandbox Code Playgroud)
从文档:
虽然一开始可能不直观,但在所有值同步发出后,时间将推进等于组中 ASCII 字符数的帧数,包括括号
好的,但是我如何测试这样的 observable(使用弹珠或任何其他技术):
const observable$ = of(1, 2).concat(of(3, 4).delay(20));
Run Code Online (Sandbox Code Playgroud)
有什么解决方法吗?
Stack Overflow 上有一个类似的问题,但没有关于“如何实际解决它并测试这种可观察的”的答案。
谢谢!
我在测试对我的效果的失败操作时遇到问题。
在这里给出一些上下文,当调用Load操作时会执行 loadProducts 效果。在效果内部执行 HTTP 请求,如果此请求成功执行,则调用LoadSuccess操作,否则调用 LoadFail。代码如下
@Effect()
loadProducts$ = this.actions$.pipe(
ofType(productActions.ProductActionTypes.Load),
mergeMap((action: productActions.Load) =>
this.productService.getProducts().pipe(
map((products: Product[]) => (new productActions.LoadSuccess(products))),
catchError(error => of(new productActions.LoadFail(error)))
))
);
Run Code Online (Sandbox Code Playgroud)
为了测试这种效果,我使用了与 jasmine-marbles 几乎相同的 jest-marbles,无论如何,我将 Load 操作创建为热可观察对象,将 http 响应创建为冷和默认的预期结果。
it('should return a LoadFail action, with an error, on failure', () => {
const action = new Load();
const errorMessage = 'Load products fail';
const outcome = new LoadFail(errorMessage);
actions$ = hot('-a', { a: action});
const response = cold('-#|', …Run Code Online (Sandbox Code Playgroud) 我现在面临一个问题.不确定如何使用过滤器运算符测试动作$.
我也试图遵循https://github.com/vsavkin/testing_ngrx_effects/tree/309b84883c2709a34ab98b696398332d33c2104f的规则
简单地说,我只是设置过滤器,如果数组的长度为0则返回true.
例如:
loadDatas$: Observable<Action> = this.actions$.ofType(LOAD_DATAS_ACTION).pipe(
withLatestFrom(this.store.select(getDatas), (action, datas) =>datas),
filter(data => !data.length),
switchMap(() => {
console.log(‘run api’);
return this.dataApi.find().pipe(
map((datas: Data[]) => new DatasLoadedAction(datas))
Run Code Online (Sandbox Code Playgroud)
.........
... ..
所以我试着写两个测试用例,一个是
expect(effects.loadDatas$).toBeObservable(expected);
Run Code Online (Sandbox Code Playgroud)
当过滤器返回true时.
但我不知道如何测试过滤器是否返回false.
你对此有什么建议吗?非常感谢
我目前想用ngrx/effects测试我的效果.我跟着降价,但是当我想要运行我的测试时我有一个错误.
Cannot find module 'rxjs/testing' from 'jasmine-marbles.umd.js'
Run Code Online (Sandbox Code Playgroud)
这是我的代码(目前我没有做到期望,我只想要我的测试运行):
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 …Run Code Online (Sandbox Code Playgroud) 我正在尝试在ubuntu上为qt5安装大理石,我正在遵循这里的步骤:https://marble.kde.org/sources.php 但是,我在安装qt大理石版本时遇到这些错误.知道如何获得Qt5ScriptConfig.cmake包吗?
命令行输出:
CMake Error at CMakeLists.txt:78 (find_package):
By not providing "FindQt5Script.cmake" in CMAKE_MODULE_PATH this project
has asked CMake to find a package configuration file provided by
"Qt5Script", but CMake did not find one.
Could not find a package configuration file provided by "Qt5Script" with
any of the following names:
Qt5ScriptConfig.cmake
qt5script-config.cmake
Add the installation prefix of "Qt5Script" to CMAKE_PREFIX_PATH or set
"Qt5Script_DIR" to a directory containing one of the above files. If
"Qt5Script" provides a separate development …Run Code Online (Sandbox Code Playgroud)