fancy-test

  • Version 1.4.10
  • Published
  • 43.9 kB
  • 8 dependencies
  • MIT license

Install

npm i fancy-test
yarn add fancy-test
pnpm add fancy-test

Overview

extendable utilities for testing

Index

Variables

variable expect

const expect: any;

    variable fancy

    const fancy: FancyTypes.Base<
    FancyTypes.Context,
    { skip: { output: unknown; args: [] } } & {
    only: { output: unknown; args: [] };
    } & { retries: { output: unknown; args: [number] } } & {
    catch: {
    output: { error: Error };
    args: [
    string | RegExp | ((err: Error) => any),
    { raiseIfNotThrown?: boolean | undefined }?
    ];
    };
    } & {
    env: {
    output: unknown;
    args: [{ [k: string]: string }, FancyTypes.EnvOptions?];
    };
    } & { stub: { output: { stubs: any[] }; args: [any, any, () => any] } } & {
    stdin: { output: unknown; args: [string, (number | undefined)?] };
    } & {
    stderr: {
    output: { readonly stderr: string };
    args: [
    (
    | {
    print?: boolean | undefined;
    stripColor?: boolean | undefined;
    }
    | undefined
    )?
    ];
    };
    } & {
    stdout: {
    output: { readonly stdout: string };
    args: [
    (
    | {
    print?: boolean | undefined;
    stripColor?: boolean | undefined;
    }
    | undefined
    )?
    ];
    };
    } & {
    nock: {
    output: { nock: number };
    args: [
    string,
    FancyTypes.NockOptions | FancyTypes.NockCallback,
    (FancyTypes.NockCallback | undefined)?
    ];
    };
    } & { timeout: { output: { timeout: number }; args: [(number | undefined)?] } }
    >;

      Type Aliases

      type Fancy

      type Fancy = typeof fancy;

        Namespaces

        namespace FancyTypes

        module 'lib/types.d.ts' {}

          interface Context

          interface Context {}

            property chain

            chain: Plugin<any>[];

              property error

              error?: Error & {
              code?: string;
              };

                property expectation

                expectation?: string;

                  property plugins

                  plugins: {
                  [k: string]: PluginBuilder<any, any>;
                  };

                    property retries

                    retries?: number;

                      property test

                      test: typeof it | typeof it.skip;

                        property timeout

                        timeout?: number;

                          interface EnvOptions

                          interface EnvOptions {}

                            property clear

                            clear?: boolean;

                              interface It

                              interface It<I> {}

                                call signature

                                (expectation: string, cb?: MochaCallback<I>): void;

                                  call signature

                                  (cb?: MochaCallback<I>): void;

                                    interface ITestCallbackContext

                                    interface ITestCallbackContext {}

                                      method retries

                                      retries: (n: number) => this;

                                        method skip

                                        skip: () => this;

                                          method slow

                                          slow: (ms: number) => this;

                                            method timeout

                                            timeout: (ms: number | string) => this;

                                              index signature

                                              [index: string]: any;

                                                interface NockOptions

                                                interface NockOptions extends Nock.Options {}

                                                  interface NockScope

                                                  interface NockScope extends Nock.Scope {}

                                                    interface Plugin

                                                    interface Plugin<I> {}

                                                      method catch

                                                      catch: (context: I) => any;

                                                        method finally

                                                        finally: (context: I) => any;

                                                          method init

                                                          init: (context: I) => any;

                                                            method run

                                                            run: (context: I) => any;

                                                              interface PluginDef

                                                              interface PluginDef {}

                                                                property args

                                                                args: any[];

                                                                  property output

                                                                  output: object | unknown;

                                                                    interface Plugins

                                                                    interface Plugins {}

                                                                      index signature

                                                                      [k: string]: PluginDef;

                                                                        type Base

                                                                        type Base<I extends Context, T extends Plugins> = {
                                                                        it: It<I>;
                                                                        end: It<I>;
                                                                        add<K extends string, O>(
                                                                        key: K,
                                                                        cb: ((context: I) => Promise<O> | O) | Promise<O> | O
                                                                        ): Base<
                                                                        I &
                                                                        {
                                                                        [P in K]: O;
                                                                        },
                                                                        T
                                                                        >;
                                                                        do<O>(cb: (context: I & O) => any): Base<O & I, T>;
                                                                        finally(cb: (context: I) => any): Base<I, T>;
                                                                        register<K extends string, O, A extends any[]>(
                                                                        key: K,
                                                                        plugin: (...args: A) => Plugin<O & I>
                                                                        ): Base<
                                                                        I,
                                                                        T &
                                                                        {
                                                                        [P in K]: {
                                                                        output: O;
                                                                        args: A;
                                                                        };
                                                                        }
                                                                        >;
                                                                        } & {
                                                                        [P in keyof T]: (...args: T[P]['args']) => Base<T[P]['output'] & I, T>;
                                                                        };

                                                                          type MochaCallback

                                                                          type MochaCallback<I> = (
                                                                          this: ITestCallbackContext,
                                                                          context: I,
                                                                          done: MochaDone
                                                                          ) => any;

                                                                            type MochaDone

                                                                            type MochaDone = (err?: any) => void;

                                                                              type NockCallback

                                                                              type NockCallback = (nock: NockScope) => any;

                                                                                type PluginBuilder

                                                                                type PluginBuilder<I, Args extends any[]> = (...args: Args) => Plugin<I>;

                                                                                  Package Files (3)

                                                                                  Dependencies (8)

                                                                                  Dev Dependencies (13)

                                                                                  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/fancy-test.

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