Code Monkey home page Code Monkey logo

streamtest's Introduction

streamtest

Streams test library

GitHub license

streamtest is a set of utils to test your stream based modules simply.

In fact, this repository's tests is a perfect example of its own usage ;).

Installation

First install streamtest in your project:

npm install --save-dev streamtest

Getting started

Then, use it:

import StreamTest from 'streamtest';

describe('My Stream Lib', () => {

  // here goes your code
  it('should work', async (done) => {
    const [outputStream, resultPromise] = StreamTest.toText();

    StreamTest.fromChunks(['a ', 'chunk', 'and', 'another'])
      .pipe(myTestedStream)
      .pipe(outputStream);

    assert.equal(await resultPromise, 'the text as i should be')
  });

});

Contribute

Feel free to submit us your improvements. To do so, you must accept to publish your code under the MIT license.

To start contributing, first run the following to setup the development environment:

git clone [email protected]:nfroidure/streamtest.git
cd streamtest
npm install

Then, run the tests:

npm test

API

StreamTest : object

Kind: global namespace

StreamTest.fromObjects(objects, timeout) ⇒

Create a readable stream streaming objects each timeout milliseconds and then end. Usefull for testing objectMode based streams.

Kind: static method of StreamTest
Returns: Readable

Param Description
objects Array
timeout number

StreamTest.fromErroredObjects(err, objects, timeout) ⇒

Create a readable stream streaming objects each timeout milliseconds, emit the err error and then end. Usefull for testing objectMode based streams.

Kind: static method of StreamTest
Returns: Readable

Param Description
err Error
objects Object[]
timeout number

StreamTest.fromChunks(chunks, timeout) ⇒

Create a readable stream streaming chunks each timeout milliseconds and then end. Usefull for testing buffer based streams.

Kind: static method of StreamTest
Returns: Readable

Param Description
chunks Buffer[]
timeout number

StreamTest.fromErroredChunks(err, objects, timeout) ⇒

Create a readable stream streaming chunks each timeout milliseconds, emit the err error and then end. Usefull for testing buffer based streams.

Kind: static method of StreamTest
Returns: Readable

Param Description
err Error
objects Object[]
timeout number

StreamTest.toObjects() ⇒

Create a writable stream collecting written objects and a promise that resolves when it finishes with the objects collected.

Kind: static method of StreamTest
Returns: [Writable, Promise]

StreamTest.toChunks() ⇒

Create a writable stream collecting written chunks and a promise that resolves when it finishes with the chunks collected.

Kind: static method of StreamTest
Returns: [Writable, Promise<Buffer[]>]

StreamTest.toText() ⇒

Create a writable stream collecting written text and a promise that resolves when it finishes with the whole text content.

Kind: static method of StreamTest
Returns: [Writable, Promise]

Authors

License

MIT

streamtest's People

Contributors

nfroidure avatar bitzl avatar estebanborai avatar kapouer avatar nikolasburk avatar

Stargazers

Eric Shinn avatar Gianluca Barbon avatar Davide avatar David Adam Coffey avatar Benno avatar Adam Wamai Egesa avatar Chris Ramón avatar Adi Fatol avatar Christopher Humphries avatar Chancey Mathews avatar David Jimenez avatar Andrea Zucchini avatar Lennart Hildebrandt avatar Matt Travi avatar Martin Donath avatar Alex Feinstein avatar Caio Kinzel Filho avatar Yusuke Abe avatar  avatar Reda avatar Alex Bjørlig avatar etpinard avatar Vlad Trukhin avatar C.S. Jiang avatar Marvin Hagemeister avatar Leland Cope avatar Busticated avatar Luis Lobo Borobia avatar  avatar

Watchers

Lucian avatar  avatar  avatar James Cloos avatar Leland Cope avatar  avatar

streamtest's Issues

New Bugfix release 1.2.2

There have been several minor Bugfixes and fixes to the documentation/README.md. The new README.md won't show up on https://www.npmjs.com/package/streamtest until we refresh the package or make a new release.

As the package is associated with @nfroidure's account on npmjs.com, I probably can't do this. Therefore, there are several options:

  • @nfroidure creates the new release and publishes to NPM
  • @bitzl gets assigned on NPM (@marcus.bitzl) to the package, creates the new release and publishes to NPM

@nfroidure we can discuss this also via Email or Gitter, if you prefer.

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.