@tapjs/test
the pluggable Test class for node-tap
Last updated 4 months ago by isaacs .
BlueOak-1.0.0 · Repository · Bugs · Original npm · Tarball · package.json
$ npm install @tapjs/test 
SYNC missed versions from official npm registry.

@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.

Current Tags

  • 4.0.0                                ...           latest (4 months ago)
  • 1.0.0                                ...           pre (a year ago)

67 Versions

  • 3.0.0                                ...           5 months ago
  • 4.0.0                                ...           4 months ago
  • 3.0.3                                ...           5 months ago
  • 3.0.2                                ...           5 months ago
  • 3.0.1                                ...           5 months ago
  • 2.2.4                                ...           5 months ago
  • 2.2.3                                ...           5 months ago
  • 2.2.2                                ...           5 months ago
  • 2.2.1                                ...           5 months ago
  • 2.2.0                                ...           5 months ago
  • 2.1.1                                ...           5 months ago
  • 2.1.0                                ...           5 months ago
  • 2.0.1                                ...           6 months ago
  • 2.0.0                                ...           6 months ago
  • 1.4.4                                ...           6 months ago
  • 1.4.3                                ...           6 months ago
  • 1.4.2                                ...           8 months ago
  • 1.4.1                                ...           8 months ago
  • 1.4.0                                ...           10 months ago
  • 1.3.17                                ...           a year ago
  • 1.3.16                                ...           a year ago
  • 1.3.15                                ...           a year ago
  • 1.3.14                                ...           a year ago
  • 1.3.13                                ...           a year ago
  • 1.3.12                                ...           a year ago
  • 1.3.11                                ...           a year ago
  • 1.3.10                                ...           a year ago
  • 1.3.9                                ...           a year ago
  • 1.3.8                                ...           a year ago
  • 1.3.7                                ...           a year ago
  • 1.3.6                                ...           a year ago
  • 1.3.5                                ...           a year ago
  • 1.3.4                                ...           a year ago
  • 1.3.3                                ...           a year ago
  • 1.3.2                                ...           a year ago
  • 1.3.1                                ...           a year ago
  • 1.3.0                                ...           a year ago
  • 1.2.0                                ...           a year ago
  • 1.1.2                                ...           a year ago
  • 1.1.1                                ...           a year ago
  • 1.1.0                                ...           a year ago
  • 1.0.3                                ...           a year ago
  • 1.0.2                                ...           a year ago
  • 1.0.1                                ...           a year ago
  • 1.0.0                                ...           a year ago
  • 0.0.0-22                                ...           a year ago
  • 0.0.0-21                                ...           a year ago
  • 0.0.0-20                                ...           a year ago
  • 0.0.0-19                                ...           a year ago
  • 0.0.0-18                                ...           a year ago
  • 0.0.0-17                                ...           a year ago
  • 0.0.0-16                                ...           a year ago
  • 0.0.0-15                                ...           a year ago
  • 0.0.0-14                                ...           a year ago
  • 0.0.0-13                                ...           a year ago
  • 0.0.0-12                                ...           a year ago
  • 0.0.0-11                                ...           a year ago
  • 0.0.0-10                                ...           a year ago
  • 0.0.0-9                                ...           a year ago
  • 0.0.0-8                                ...           a year ago
  • 0.0.0-7                                ...           a year ago
  • 0.0.0-6                                ...           a year ago
  • 0.0.0-5                                ...           a year ago
  • 0.0.0-4                                ...           a year ago
  • 0.0.0-3                                ...           a year ago
  • 0.0.0-2                                ...           a year ago
  • 0.0.0-1                                ...           a year ago
Maintainers (2)
Downloads
Total 4
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dev Dependencies (0)
None

© 2010 - cnpmjs.org x YWFE | Home | YWFE