doowb / Capture Stream
Licence: mit
Capture stream output.
Stars: ✭ 10
Programming Languages
javascript
184084 projects - #8 most used programming language
Projects that are alternatives of or similar to Capture Stream
unittest expander
A library that provides flexible and easy-to-use tools to parameterize Python unit tests, especially those based on unittest.TestCase.
Stars: ✭ 12 (+20%)
Mutual labels: unit-testing, test, tests, unittest
Wasmite
Now WebAssembly has proper testing, unit-testing and debugging 🤗
Stars: ✭ 20 (+100%)
Mutual labels: unit-testing, test, unittest
flyway-junit5-extensions
Flyway JUnit 5 Extension to clean / migrate your database in tests.
Stars: ✭ 14 (+40%)
Mutual labels: test, tests
Django Jenkins
Plug and play continuous integration with django and jenkins
Stars: ✭ 933 (+9230%)
Mutual labels: test, unit-testing
local-data-api
Data API for local, you can write unittest for AWS Aurora Serverless's Data API
Stars: ✭ 99 (+890%)
Mutual labels: test, unittest
teuton
Infrastructure test, mainly useful for sysadmin teachers and making contests
Stars: ✭ 22 (+120%)
Mutual labels: unit-testing, test
fake-sftp-server-rule
A JUnit rule that runs an in-memory SFTP server.
Stars: ✭ 34 (+240%)
Mutual labels: test, unittest
Unit Testing Tips
Unit testing tips by examples in PHP
Stars: ✭ 318 (+3080%)
Mutual labels: unit-testing, tests
Dredd
Language-agnostic HTTP API Testing Tool
Stars: ✭ 3,770 (+37600%)
Mutual labels: unit-testing, tests
dojos
Alguns desafios para os participantes dos grupos de estudo
Stars: ✭ 33 (+230%)
Mutual labels: test, tests
Telegraf-Test
Telegraf Test - Simple Test ToolKit of Telegram Bots
Stars: ✭ 22 (+120%)
Mutual labels: test, tests
node-bogota
🚀 Run tape tests concurrently with tap-spec output
Stars: ✭ 15 (+50%)
Mutual labels: test, tests
Bash unit
bash unit testing enterprise edition framework for professionals
Stars: ✭ 419 (+4090%)
Mutual labels: unit-testing, unittest
Goreporter
A Golang tool that does static analysis, unit testing, code review and generate code quality report.
Stars: ✭ 2,943 (+29330%)
Mutual labels: test, unit-testing
capture-stream
Capture stream output.
Install
Install with npm:
$ npm install capture-stream --save
Usage
var capture = require('capture-stream');
var restore = capture(process.stdout);
console.log('Hello, world!!!');
console.log('foo', 'bar');
var output = restore();
console.log(output);
//=> [ [ 'Hello, world!!!\n' ], [ 'foo bar\n' ] ]
Pass true
to restore
to return a string instead of an array of output.
var capture = require('capture-stream');
var restore = capture(process.stdout);
console.log('Hello, world!!!');
console.log('foo', 'bar');
var output = restore(true);
console.log(output);
//=> Hello, world!!!
//=> foo bar
//=>
This module has been built to be used in unit tests to easily capture output from process.stdout
and process.stderr
and test the results.
describe('awesome module', function () {
function log () {
console.log.apply(console, arguments);
}
it('should write "Hello, world!!!" to stdout', function () {
var restore = capture(process.stdout);
log('Hello, world!!!');
var output = restore();
assert.equal(output.length, 1);
assert(output[0][0].indexOf('Hello, world!!!') === 0);
});
});
API
captureStream
Capture the output from a stream and store later.
Params
-
stream
{Stream}: A stream to capture output from (e.g.process.stdout
,process.stderr
) -
returns
{Function}restore
: function that restores normal output and returns an array of output.
Example
var restore = capture(process.stdout);
console.log('Hello, world!!!');
console.log('foo', 'bar');
var output = restore();
console.log(output);
//=> [ [ 'Hello, world!!!\n' ], [ 'foo bar\n' ] ]
Related projects
- composer-errors: Listen for and output Composer errors. | homepage
- composer-runtimes: Write composer task start and end times to a stream. | homepage
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Building docs
Generate readme and API documentation with [verb][]:
$ npm install verb && npm run docs
Or, if [verb][] is installed globally:
$ verb
Running tests
Install dev dependencies:
$ npm install -d && npm test
Author
Brian Woodward
License
Copyright © 2016 Brian Woodward Released under the MIT license.
This file was generated by verb, v0.9.0, on March 19, 2016.
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].