@types/tape

  • Version 4.13.2
  • Published
  • 15.3 kB
  • 1 dependency
  • 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: () => 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) => any;
  • 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 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 preceeding tests have finished. Tests execute serially.

Interfaces

interface AssertOptions

interface AssertOptions {}
  • Available options for tape assertions.

property message

message?: string | undefined;

    property skip

    skip?: boolean | string | undefined;

      property todo

      todo?: boolean | string | undefined;

        interface StreamOptions

        interface StreamOptions {}
        • Options for the createStream function.

        property objectMode

        objectMode?: boolean | undefined;

          interface Test

          interface Test {}

            method assert

            assert: (value: any, msg?: string, extra?: AssertOptions) => void;

              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 deepEquals

              deepEquals: (
              actual: any,
              expected: any,
              msg?: string,
              extra?: AssertOptions
              ) => void;

                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 doesNotEqual

                doesNotEqual: (
                actual: any,
                expected: any,
                msg?: string,
                extra?: AssertOptions
                ) => void;

                  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): void;
                  (fn: () => void, exceptionExpected: Function | RegExp, msg?: string): 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 equals

                  equals: (
                  actual: any,
                  expected: any,
                  msg?: string,
                  extra?: AssertOptions
                  ) => void;

                    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 false

                    false: (value: any, msg?: string, extra?: AssertOptions) => void;

                      method ifErr

                      ifErr: (err: any, msg?: string, extra?: AssertOptions) => void;

                        method iferror

                        iferror: (err: any, msg?: string, extra?: AssertOptions) => void;

                          method ifError

                          ifError: (err: any, msg?: string, extra?: AssertOptions) => void;

                            method is

                            is: (actual: any, expected: any, msg?: string, extra?: AssertOptions) => void;

                              method isEqual

                              isEqual: (
                              actual: any,
                              expected: any,
                              msg?: string,
                              extra?: AssertOptions
                              ) => void;

                                method isEquivalent

                                isEquivalent: (
                                actual: any,
                                expected: any,
                                msg?: string,
                                extra?: AssertOptions
                                ) => void;

                                  method isInequal

                                  isInequal: (
                                  actual: any,
                                  expected: any,
                                  msg?: string,
                                  extra?: AssertOptions
                                  ) => void;

                                    method isInequivalent

                                    isInequivalent: (
                                    actual: any,
                                    expected: any,
                                    msg?: string,
                                    extra?: AssertOptions
                                    ) => void;

                                      method isNot

                                      isNot: (actual: any, expected: any, msg?: string, extra?: AssertOptions) => void;

                                        method isNotDeepEqual

                                        isNotDeepEqual: (
                                        actual: any,
                                        expected: any,
                                        msg?: string,
                                        extra?: AssertOptions
                                        ) => void;

                                          method isNotDeeply

                                          isNotDeeply: (
                                          actual: any,
                                          expected: any,
                                          msg?: string,
                                          extra?: AssertOptions
                                          ) => void;

                                            method isNotEqual

                                            isNotEqual: (
                                            actual: any,
                                            expected: any,
                                            msg?: string,
                                            extra?: AssertOptions
                                            ) => void;

                                              method isNotEquivalent

                                              isNotEquivalent: (
                                              actual: any,
                                              expected: any,
                                              msg?: string,
                                              extra?: AssertOptions
                                              ) => void;

                                                method looseEqual

                                                looseEqual: (
                                                actual: any,
                                                expected: any,
                                                msg?: string,
                                                extra?: AssertOptions
                                                ) => void;

                                                  method looseEquals

                                                  looseEquals: (
                                                  actual: any,
                                                  expected: any,
                                                  msg?: string,
                                                  extra?: AssertOptions
                                                  ) => void;

                                                    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 not

                                                    not: (actual: any, expected: any, msg?: string, extra?: AssertOptions) => void;

                                                      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 notDeeply

                                                      notDeeply: (
                                                      actual: any,
                                                      expected: any,
                                                      msg?: string,
                                                      extra?: AssertOptions
                                                      ) => void;

                                                        method notEqual

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

                                                        method notEquals

                                                        notEquals: (
                                                        actual: any,
                                                        expected: any,
                                                        msg?: string,
                                                        extra?: AssertOptions
                                                        ) => void;

                                                          method notEquivalent

                                                          notEquivalent: (
                                                          actual: any,
                                                          expected: any,
                                                          msg?: string,
                                                          extra?: AssertOptions
                                                          ) => void;

                                                            method notLooseEqual

                                                            notLooseEqual: (
                                                            actual: any,
                                                            expected: any,
                                                            msg?: string,
                                                            extra?: AssertOptions
                                                            ) => void;

                                                              method notLooseEquals

                                                              notLooseEquals: (
                                                              actual: any,
                                                              expected: any,
                                                              msg?: string,
                                                              extra?: AssertOptions
                                                              ) => void;

                                                                method notok

                                                                notok: (value: any, msg?: string, extra?: AssertOptions) => void;

                                                                  method notOk

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

                                                                  method notSame

                                                                  notSame: (
                                                                  actual: any,
                                                                  expected: any,
                                                                  msg?: string,
                                                                  extra?: AssertOptions
                                                                  ) => void;

                                                                    method notStrictEqual

                                                                    notStrictEqual: (
                                                                    actual: any,
                                                                    expected: any,
                                                                    msg?: string,
                                                                    extra?: AssertOptions
                                                                    ) => void;

                                                                      method notStrictEquals

                                                                      notStrictEquals: (
                                                                      actual: any,
                                                                      expected: any,
                                                                      msg?: string,
                                                                      extra?: AssertOptions
                                                                      ) => void;

                                                                        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 same

                                                                        same: (actual: any, expected: any, msg?: string, extra?: AssertOptions) => void;

                                                                          method skip

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

                                                                          method strictEqual

                                                                          strictEqual: (
                                                                          actual: any,
                                                                          expected: any,
                                                                          msg?: string,
                                                                          extra?: AssertOptions
                                                                          ) => void;

                                                                            method strictEquals

                                                                            strictEquals: (
                                                                            actual: any,
                                                                            expected: any,
                                                                            msg?: string,
                                                                            extra?: AssertOptions
                                                                            ) => void;

                                                                              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): void;
                                                                              (fn: () => void, exceptionExpected: Function | RegExp, msg?: string): void;
                                                                              };
                                                                              • Assert that the function call fn() throws an exception. expected, if present, must be a RegExp or Function, which is used to test the exception object.

                                                                              method timeoutAfter

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

                                                                              method true

                                                                              true: (value: any, msg?: string, extra?: AssertOptions) => void;

                                                                                interface TestCase

                                                                                interface TestCase {}

                                                                                  call signature

                                                                                  (test: Test): void;

                                                                                    interface TestOptions

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

                                                                                    property skip

                                                                                    skip?: boolean | undefined;

                                                                                      property timeout

                                                                                      timeout?: number | undefined;

                                                                                        property todo

                                                                                        todo?: boolean | undefined;

                                                                                          Package Files (1)

                                                                                          Dependencies (1)

                                                                                          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>