npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@tapjs/test

v4.0.0

Published

the pluggable Test class for node-tap

Downloads

604,630

Readme

@tapjs/test

The plugin-ified Test class in node-tap.

Class Test

This is the object that's actually provided to your tests. When you do t.pass('this is fine'), this is the t.

It's also the base class of the TAP class which is the default export of the 'tap' module, so anything on Test is also on TAP.

The Test class itself adds only the following methods, but it has the sum of all methods provided by all loaded plugins.

t.applyPlugin(plugin: TapPlugin): Test

This returns a new version of the Test object which has the plugin applied.

Note that it's actually a different object, but anything done to the copy will also affect the base, and it will inherit all properties and methods that the base has, so the new object can be used in place of the original.

For example:

import t from 'tap'

const plugin = t => ({
  hello: () => console.log('hello from ', t.name),
  blowUp: () => t.fail('blowing up'),
})

t.test('apply a plugin', original => {
  const t = original.applyPlugin(plugin)
  console.log(typeof original.hello) // 'undefined'
  console.log(typeof t.hello) // 'function'
  t.hello()
  t.blowUp()
  console.log(original.passing()) // false
  t.end() // ends the subtest
})

t.pluginLoaded(plugin: TapPlugin): boolean

Returns true if the plugin is loaded.

Also asserts that t implements the type returned by the plugin function.

So, for example, if a plugin might be loaded, you can use this to get TypeScript to know about it.

import t from 'tap'
import { Test } from '@tapjs/test'

const plugin = t => ({
  hello: () => console.log('hello from ', t.name),
  blowUp: () => t.fail('blowing up'),
})

const maybeBlowup = (t: Test) => {
  if (t.pluginLoaded(plugin)) {
    t.blowUp()
  } else {
    t.pass('no blowup required')
  }
}

t.test('maybe blow up', original => {
  const t = original.applyPlugin(plugin)
  maybeBlowup(original) // emits passing 'no blowup required'
  maybeBlowup(t) // blows up
  t.end()
})

t.test(), t.todo(), t.skip()

Creates a subtest. You've seen this one before. This is the class that implements it.

signature: string

The signature of the plugins built into this Test class.

loaders: string[]

The loaders added by plugins.

testFileExtensions: Set<string>

The test file extensions added by plugins.