@types/tape

  • Version 5.6.4
  • Published
  • 14.4 kB
  • 2 dependencies
  • MIT license

Install

npm i @types/tape
yarn add @types/tape
pnpm add @types/tape

Overview

TypeScript definitions for tape

Index

Functions

function createHarness

createHarness: (opts?: { autoclose?: boolean; noOnly?: boolean }) => typeof tape;
  • Create a new test harness instance, which is a function like test(), but with a new pending stack and test state.

function createStream

createStream: (opts?: tape.StreamOptions) => NodeJS.ReadableStream;
  • Create a stream of output, bypassing the default output stream that writes messages to console.log(). By default stream will be a text stream of TAP output, but you can get an object stream instead by setting opts.objectMode to true.

function getHarness

getHarness: (
opts?: {
noOnly?: boolean;
exit?: boolean;
stream?: ReturnType<typeof import('through')>;
} & StreamOptions
) => typeof tape;
  • Create a memoized test harness instance, which is a function like test(), but with a new pending stack and test state.

function onFailure

onFailure: (cb: () => void) => void;
  • The onFailure hook will get invoked whenever any tape tests have failed.

function onFinish

onFinish: (cb: () => void) => void;
  • The onFinish hook will get invoked when ALL tape tests have finished right before tape is about to print the test summary.

function only

only: {
(name: string, cb: tape.TestCase): void;
(name: string, opts: TestOptions, cb: TestCase): void;
(cb: TestCase): void;
(opts: TestOptions, cb: TestCase): void;
};
  • Like test(name?, opts?, cb) except if you use .only this is the only test case that will run for the entire process, all other test cases using tape will be ignored.

function skip

skip: {
(name: string, cb: tape.TestCase): void;
(name: string, opts: TestOptions, cb: TestCase): void;
(cb: TestCase): void;
(opts: TestOptions, cb: TestCase): void;
};
  • Generate a new test that will be skipped over.

function tape

tape: typeof tape;
  • Create a new test with an optional name string and optional opts object. cb(t) fires with the new test object t once all preceding tests have finished. Tests execute serially.

Interfaces

interface AssertOptions

interface AssertOptions {}
  • Available options for tape assertions.

property message

message?: string | undefined;
  • An optional description of the assertion.

property skip

skip?: boolean | string | undefined;
  • Skip the assertion. Can also be a message explaining why the test is skipped.

property todo

todo?: boolean | string | undefined;
  • Allows the assertion to fail.

interface StreamOptions

interface StreamOptions {}
  • Options for the createStream function.

property objectMode

objectMode?: boolean | undefined;

    interface Test

    interface Test {}

      property assert

      assert: Test['ok'];

        property deepEquals

        deepEquals: Test['deepEqual'];

          property doesNotEqual

          doesNotEqual: Test['notEqual'];

            property equals

            equals: Test['equal'];

              property false

              false: Test['notOk'];

                property ifErr

                ifErr: Test['error'];

                  property iferror

                  iferror: Test['error'];

                    property ifError

                    ifError: Test['error'];

                      property is

                      is: Test['equal'];

                        property isEqual

                        isEqual: Test['equal'];

                          property isEquivalent

                          isEquivalent: Test['deepEqual'];

                            property isInequal

                            isInequal: Test['notEqual'];

                              property isInequivalent

                              isInequivalent: Test['notDeepEqual'];

                                property isNot

                                isNot: Test['notEqual'];

                                  property isNotDeepEqual

                                  isNotDeepEqual: Test['notDeepEqual'];

                                    property isNotDeeply

                                    isNotDeeply: Test['notDeepEqual'];

                                      property isNotEqual

                                      isNotEqual: Test['notEqual'];

                                        property isNotEquivalent

                                        isNotEquivalent: Test['notDeepEqual'];

                                          property looseEquals

                                          looseEquals: Test['looseEqual'];

                                            property not

                                            not: Test['notEqual'];

                                              property notDeeply

                                              notDeeply: Test['notDeepEqual'];

                                                property notEquals

                                                notEquals: Test['notEqual'];

                                                  property notEquivalent

                                                  notEquivalent: Test['notDeepEqual'];

                                                    property notLooseEquals

                                                    notLooseEquals: Test['looseEqual'];

                                                      property notok

                                                      notok: Test['notOk'];

                                                        property notSame

                                                        notSame: Test['notDeepEqual'];

                                                          property notStrictEqual

                                                          notStrictEqual: Test['notEqual'];

                                                            property notStrictEquals

                                                            notStrictEquals: Test['notEqual'];

                                                              property same

                                                              same: Test['deepEqual'];

                                                                property strictEqual

                                                                strictEqual: Test['equal'];

                                                                  property strictEquals

                                                                  strictEquals: Test['equal'];

                                                                    property true

                                                                    true: Test['ok'];

                                                                      method comment

                                                                      comment: (msg: string) => void;
                                                                      • Print a message without breaking the tap output. (Useful when using e.g. tap-colorize where output is buffered & console.log will print in incorrect order vis-a-vis tap output.)

                                                                      method deepEqual

                                                                      deepEqual: (
                                                                      actual: any,
                                                                      expected: any,
                                                                      msg?: string,
                                                                      extra?: AssertOptions
                                                                      ) => void;
                                                                      • Assert that a and b have the same structure and nested values using node's deepEqual() algorithm with strict comparisons (===) on leaf nodes and an optional description msg.

                                                                      method deepLooseEqual

                                                                      deepLooseEqual: (
                                                                      actual: any,
                                                                      expected: any,
                                                                      msg?: string,
                                                                      extra?: AssertOptions
                                                                      ) => void;
                                                                      • Assert that a and b have the same structure and nested values using node's deepEqual() algorithm with loose comparisons (==) on leaf nodes and an optional description msg.

                                                                      method doesNotMatch

                                                                      doesNotMatch: (
                                                                      actual: string,
                                                                      expected: RegExp,
                                                                      msg?: string,
                                                                      extra?: AssertOptions
                                                                      ) => void;
                                                                      • Assert that string does not match the RegExp regexp. Will throw (not just fail) when the first two arguments are the wrong type.

                                                                      method doesNotThrow

                                                                      doesNotThrow: {
                                                                      (fn: () => void, msg?: string, extra?: AssertOptions): void;
                                                                      (
                                                                      fn: () => void,
                                                                      exceptionExpected: Function | RegExp,
                                                                      msg?: string,
                                                                      extra?: AssertOptions
                                                                      ): void;
                                                                      };
                                                                      • Assert that the function call fn() does not throw an exception.

                                                                      method end

                                                                      end: (err?: any) => void;
                                                                      • Declare the end of a test explicitly. If err is passed in t.end will assert that it is falsey.

                                                                      method equal

                                                                      equal: (actual: any, expected: any, msg?: string, extra?: AssertOptions) => void;
                                                                      • Assert that a === b with an optional description msg.

                                                                      method error

                                                                      error: (err: any, msg?: string, extra?: AssertOptions) => void;
                                                                      • Assert that err is falsy. If err is non-falsy, use its err.message as the description message.

                                                                      method fail

                                                                      fail: (msg?: string, extra?: AssertOptions) => void;
                                                                      • Generate a failing assertion with a message msg.

                                                                      method looseEqual

                                                                      looseEqual: (
                                                                      actual: any,
                                                                      expected: any,
                                                                      msg?: string,
                                                                      extra?: AssertOptions
                                                                      ) => void;
                                                                      • Assert that actual == expected with an optional description of the assertion msg.

                                                                      method match

                                                                      match: (
                                                                      actual: string,
                                                                      expected: RegExp,
                                                                      msg?: string,
                                                                      extra?: AssertOptions
                                                                      ) => void;
                                                                      • Assert that string matches the RegExp regexp. Will throw (not just fail) when the first two arguments are the wrong type.

                                                                      method notDeepEqual

                                                                      notDeepEqual: (
                                                                      actual: any,
                                                                      expected: any,
                                                                      msg?: string,
                                                                      extra?: AssertOptions
                                                                      ) => void;
                                                                      • Assert that a and b do not have the same structure and nested values using node's deepEqual() algorithm with strict comparisons (===) on leaf nodes and an optional description msg.

                                                                      method notDeepLooseEqual

                                                                      notDeepLooseEqual: (
                                                                      actual: any,
                                                                      expected: any,
                                                                      msg?: string,
                                                                      extra?: AssertOptions
                                                                      ) => void;
                                                                      • Assert that a and b do not have the same structure and nested values using node's deepEqual() algorithm with loose comparisons (==) on leaf nodes and an optional description msg.

                                                                      method notEqual

                                                                      notEqual: (
                                                                      actual: any,
                                                                      expected: any,
                                                                      msg?: string,
                                                                      extra?: AssertOptions
                                                                      ) => void;
                                                                      • Assert that a !== b with an optional description msg.

                                                                      method notLooseEqual

                                                                      notLooseEqual: (
                                                                      actual: any,
                                                                      expected: any,
                                                                      msg?: string,
                                                                      extra?: AssertOptions
                                                                      ) => void;
                                                                      • Assert that actual != expected with an optional description of the assertion msg.

                                                                      method notOk

                                                                      notOk: (value: any, msg?: string, extra?: AssertOptions) => void;
                                                                      • Assert that value is falsy with an optional description message msg.

                                                                      method ok

                                                                      ok: (value: any, msg?: string, extra?: AssertOptions) => void;
                                                                      • Assert that value is truthy with an optional description message msg.

                                                                      method pass

                                                                      pass: (msg?: string, extra?: AssertOptions) => void;
                                                                      • Generate a passing assertion with a message msg.

                                                                      method plan

                                                                      plan: (n: number) => void;
                                                                      • Declare that n assertions should be run. end() will be called automatically after the nth assertion. If there are any more assertions after the nth, or after end() is called, they will generate errors.

                                                                      method skip

                                                                      skip: (msg?: string, extra?: AssertOptions) => void;
                                                                      • Generate an assertion that will be skipped over.

                                                                      method teardown

                                                                      teardown: (callback: () => void | Promise<void>) => void;
                                                                      • Register a callback to run after the individual test has completed. Multiple registered teardown callbacks will run in order.

                                                                      method test

                                                                      test: {
                                                                      (name: string, cb: tape.TestCase): void;
                                                                      (name: string, opts: TestOptions, cb: TestCase): void;
                                                                      };
                                                                      • Create a subtest with a new test handle st from cb(st) inside the current test. cb(st) will only fire when t finishes. Additional tests queued up after t will not be run until all subtests finish.

                                                                      method throws

                                                                      throws: {
                                                                      (fn: () => void, msg?: string, extra?: AssertOptions): void;
                                                                      (
                                                                      fn: () => void,
                                                                      exceptionExpected: object,
                                                                      msg?: string,
                                                                      extra?: AssertOptions
                                                                      ): void;
                                                                      };
                                                                      • Assert that the function call fn() throws an exception. expected, if present, must be a RegExp, Function, or Object.

                                                                      method timeoutAfter

                                                                      timeoutAfter: (ms: number) => void;
                                                                      • Automatically timeout the test after X ms.

                                                                      interface TestCase

                                                                      interface TestCase {}

                                                                        call signature

                                                                        (test: Test): void | Promise<void>;

                                                                          interface TestOptions

                                                                          interface TestOptions {}
                                                                          • Available opts options for the tape function.

                                                                          property objectPrintDepth

                                                                          objectPrintDepth?: number | undefined;
                                                                          • Configure max depth of expected/actual object printing. Environmental variable NODE_TAPE_OBJECT_PRINT_DEPTH can set the desired default depth for all tests; locally-set values will take precedence.

                                                                          property skip

                                                                          skip?: boolean | undefined;
                                                                          • See test.skip.

                                                                          property timeout

                                                                          timeout?: number | undefined;
                                                                          • Set a timeout for the test, after which it will fail. See tape.timeoutAfter.

                                                                          property todo

                                                                          todo?: boolean | undefined;
                                                                          • Test will be allowed to fail.

                                                                          Package Files (1)

                                                                          Dependencies (2)

                                                                          Dev Dependencies (0)

                                                                          No dev dependencies.

                                                                          Peer Dependencies (0)

                                                                          No peer dependencies.

                                                                          Badge

                                                                          To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                          You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@types/tape.

                                                                          • Markdown
                                                                            [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@types/tape)
                                                                          • HTML
                                                                            <a href="https://www.jsdocs.io/package/@types/tape"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>