https://github.com/boneskull/unexpected-rxjs
MOVED to https://github.com/IBM/unexpected-rxjs
https://github.com/boneskull/unexpected-rxjs
assert assertion-library assertions expect observable rxjs test unexpected
Last synced: 5 months ago
JSON representation
MOVED to https://github.com/IBM/unexpected-rxjs
- Host: GitHub
- URL: https://github.com/boneskull/unexpected-rxjs
- Owner: boneskull
- License: apache-2.0
- Archived: true
- Created: 2019-06-14T17:31:14.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2021-06-07T22:26:50.000Z (over 4 years ago)
- Last Synced: 2025-08-08T14:13:25.173Z (5 months ago)
- Topics: assert, assertion-library, assertions, expect, observable, rxjs, test, unexpected
- Language: JavaScript
- Homepage: https://github.com/IBM/unexpected-rxjs
- Size: 293 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# unexpected-rxjs
> Assertions for use with [RxJS](https://rjxs.dev) and [Unexpected](http://unexpected.js.org)
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.
```shell
$ npm install rxjs@^6 # peer dependency
$ npm install unexpected unexpected-rxjs --save-dev
```
## Usage
Use as an Unexpected plugin in Node.js:
```js
const unexpected = require('unexpected');
const expect = unexpected.clone().use(require('unexpected-rxjs'));
```
Or using ES modules:
```js
import unexpected from 'unexpected';
import unexpectedRxjs from 'unexpected-rxjs';
const expect = unexpected.clone().use(unexpectedRxjs);
```
Browser, using globals:
```js
const unexpected = window.weknowhow.expect;
const expect = unexpected.clone().use(window.unexpectedRxjs);
```
Then:
```js
import {of} from 'rxjs';
describe('contrived example', function() {
it('should emit "foo"', function() {
return expect(of('foo', 'bar'), 'to emit values', 'foo', 'bar');
});
});
```
## Assertions
_Note_: All assertions return `Promise` values, so you will want to `return expect(/*...*/)` (using Mocha) or otherwise use `async` functions.
- ` to complete` - Asserts an `Observable` completes. Given the halting problem, this can _only_ fail if the `Observable` emits an error _or_ your test framework times out.
- ` [not] to emit (value|values) ` - Asserts an `Observable` emits one or more values using object equivalence.
- ` [not] to emit times ` - Asserts an `Observable` emits _count_ times.
- ` [not] to emit (once|twice|thrice)` - Sugar for previous assertion.
- ` [not] to emit error ` - Asserts an `Observable` emits an "error"; uses Unexpected's default error matching.
- ` to emit error [exhaustively] satisfying ` - Asserts an `Observable` emits an "error" using "to satisfy" semantics.
- ` [not] to complete with value ` - Assert when an `Observable` completes, it has emitted one or more matching values.
- ` [not] to complete with value [exhaustively] satisfying ` - Same as previous, except using "to satisfy" semantics.
- ` when complete ` - Akin to Unexpected's ` when fulfilled ` syntax.
## Development
Execute `npm run build` to bundle the project for distribution.
## Notes
- ` [not] to complete with value [exhaustively] satisfying ` has some significant performance issues.
## License
Copyright © 2019 IBM. Licensed Apache-2.0