JSPM

fixture-stdout

0.1.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 778
  • Score
    100M100P100Q88009F
  • License MIT

A test fixture to intercept writes to stdout.

Package Exports

  • fixture-stdout

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (fixture-stdout) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

fixture-stdout

A test fixture to intercept writes to stdout.

Install:

npm install fixture-stdout

Example Usage:

var StdOutFixture = require('fixture-stdout');
var fixture = new StdOutFixture();

// Keep track of writes so we can check them later..
var _writes = [];

// Capture a write to stdout
fixture.capture( function onWrite (string, encoding, fd) {
  _writes.push({
    string: string,
    encoding: encoding,
    fd: fd
  });
});

// Uses intercepted version of stdout
console.log('a');
console.log('b');

fixture.release();

// Now we're back to the original version of stdout
console.log('c');
console.log('d');

// Voila!
// Only the first two logs ("a" and "b") are in our `_writes` array

Credit

Based on @pguillory's example.

License

MIT