RxJS Marble Testing Setup for Ava
Helpers for using marble testing. with Ava testing framework
Note: This project was derived from rxjs-marble-testing for Jasmine/Wallaby.
Marble testing resources:
Status
It works :)
Currently depends on:
- rxjs:
^5.0.0
- ava:
^0.18.0
Getting Started
npm install rxjs-ava-marble-testing --save-dev
From your Terminal run:
ava --init
Follow steps in using Ava guide
Marble Test API
cold(marbles, values?, error?)
hot(marbles, values?, error?)
expectObservable(actualObservable)
expectSubscriptions(actualSubscriptions)
ajax
withMockWebSocket
andMockXMLHttpRequest
Example usage
;;;; ; //Example with expectSubscription
Ajax Mock helpers
MockWebSocket
MockXMLHttpRequest
Usage:
import { ajax } from 'rxjs-ava-marble-testing'
MockWebSocket class API
constructor(public url: string, public protocol: string)
Instance:
send(data: any): void
get lastMessageSent(): any
triggerClose(e: any): void
triggerError(err: any): void
triggerMessage(data: any): void
open(): void
close(code: any, reason: any): void
addEventListener(name: string, handler: any): void
removeEventListener(name: string, handler: any): void
trigger(name: string, e: any)
Static:
get lastSocket(): MockWebSocket
clearSockets(): void
MockXMLHttpRequest class API
constructor()
Instance:
send(data: any): void
open(method: any, url: any, async: any, user: any, password: any): void
setRequestHeader(key: any, value: any): void
addEventListener(name: string, handler: any): void
removeEventListener(name: string, handler: any): void
throwError(err: any): void
respondWith(response: any): void
triggerEvent(name: any, eventObj?: any): void
Static:
get mostRecent(): MockXMLHttpRequest
get allRequests(): Array<MockXMLHttpRequest>
clearRequest(): void
Copyright
MIT