New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

masking-tape

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

masking-tape

a tape harness with life-cycle hooks.

  • 0.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-60%
Maintainers
1
Weekly downloads
 
Created
Source

Masking-Tape

A tape test harness with "beforeEach", "afterEach", and "afterAll" lifecycle hooks. Also lets you add an identifying comment to the beginning of each test file's run.

Example:

var mask = require('masking-tape')

// a pretend module that overrides http requests, like sinon's fakeServer,
// perhaps
var mockServer = require('mock-server') 

var server = new mockServer
var test = mask('my bestest test', afterAll, beforeEach, afterEach)

function beforeEach() {
  // maybe we've got a dom available.
  document.body.innerHTML = '<div>test html</div>'
}

function afterEach() {
  server.removeAllEndpoints()
}


function afterAll() {
  mockServer.teardownAll()
}

test('my coolestest test', function(t) {
  /* 
   * This is just a normal tape test.
  */
  t.end()
})

API:

var test = mask(name, afterAll, beforeEach, afterEach)

Arguments

  • name: a string to be printed as a comment before the test runs. Can have multiple lines: Each line will have # prepended to it.

  • afterAll: A function to be run after each test completes. This is necessary because by default tape runs all tests in the same environment, so leaving it out can pollute your test run.

  • beforeEach: A function to be run before each test begins. There is no functionality to schedule the next test after an asynchronous process specified in before completes. The next test will be queued as soon as this function returns.

  • afterEach: A function to be run after each tests completes. masking-tape does not support asynchronous function calls here, meaning that the next test will be queued as soon as this function returns.

Errors occurring in these functions are unhandled. Tracebacks should be easy to follow because of the complete lack of asynchronous support.

Return Value

A tape test harness.

Note:

The function returned by require('masking-tape') has an attribute attached to it called .stream. require('masking-tape').stream is a function that returns a stream. tape's stream of text data is piped into the returned stream in order to report test results. The "class" method is available to support tests, but you could also use it to report test results across a network, or in a browser. The default stream lives in lib/reporter.js

Why should I use this module as opposed to <insert module here>

This module implements its functionality without overriding any tape methods, or adding unnecessary clutter to tape's output. It simply makes a test harness, and creates an object stream which informs the client of the test's life-cycle.

The only caveat is we had to write a custom reporter stream for writing to stdout, since tape does not expose the reporter it uses internally.

Contributing:

Please see the contributing guidelines.

License:

APACHE V2

Keywords

FAQs

Package last updated on 06 Jan 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc