Coder Social home page Coder Social logo

unexpected-rxjs's Introduction

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 Observables.

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 = require('unexpected');
const expect = unexpected.clone().use(require('unexpected-rxjs'));

Or using ES modules:

import unexpected from 'unexpected';
import unexpectedRxjs from 'unexpected-rxjs';
const expect = unexpected.clone().use(unexpectedRxjs);

Browser, using globals:

const unexpected = window.weknowhow.expect;
const expect = unexpected.clone().use(window.unexpectedRxjs);

Then:

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.

  • <Observable> 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.
  • <Observable> [not] to emit (value|values) <any+> - Asserts an Observable emits one or more values using object equivalence.
  • <Observable> [not] to emit times <count> - Asserts an Observable emits count times.
  • <Observable> [not] to emit (once|twice|thrice) - Sugar for previous assertion.
  • <Observable> [not] to emit error <any?> - Asserts an Observable emits an "error"; uses Unexpected's default error matching.
  • <Observable> to emit error [exhaustively] satisfying <any> - Asserts an Observable emits an "error" using "to satisfy" semantics.
  • <Observable> [not] to complete with value <any+> - Assert when an Observable 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

unexpected-rxjs's People

Contributors

boneskull avatar dependabot[bot] avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.