unexpected-rxjs
Assertions for use with RxJS and Unexpected
This module is a plugin for the Unexpected assertion library which provides handy assertions against RxJS Observable
s.
Install
Both rxjs
and unexpected
are peer dependencies of this module.
$ npm install rxjs@^6 # peer dependency $ npm install unexpected unexpected-rxjs --save-dev
Usage
Use as an Unexpected plugin in Node.js:
const unexpected = ;const expect = unexpected;
Or using ES modules:
;;const expect = unexpected;
Browser, using globals:
const unexpected = windowweknowhowexpect;const expect = unexpected;
Then:
; ;
Assertions
Note: All assertions return Promise
values, so you will want to return expect(/*...*/)
(using Mocha) or otherwise use async
functions.
<Observable> to complete
- Asserts anObservable
completes. Given the halting problem, this can only fail if theObservable
emits an error or your test framework times out.<Observable> [not] to emit (value|values) <any+>
- Asserts anObservable
emits one or more values using object equivalence.<Observable> [not] to emit times <count>
- Asserts anObservable
emits count times.<Observable> [not] to emit (once|twice|thrice)
- Sugar for previous assertion.<Observable> [not] to emit error <any?>
- Asserts anObservable
emits an "error"; uses Unexpected's default error matching.<Observable> to emit error [exhaustively] satisfying <any>
- Asserts anObservable
emits an "error" using "to satisfy" semantics.<Observable> [not] to complete with value <any+>
- Assert when anObservable
completes, it has emitted one or more matching values.<Observable> [not] to complete with value [exhaustively] satisfying <any+>
- Same as previous, except using "to satisfy" semantics.<Observable> when complete <assertion>
- Akin to Unexpected's<Promise> when fulfilled <assertion>
syntax.
Development
Execute npm run build
to bundle the project for distribution.
Notes
<Observable> [not] to complete with value [exhaustively] satisfying <any+>
has some significant performance issues.
License
Copyright © 2019 IBM. Licensed Apache-2.0