fancy-test

  • Version 3.0.16
  • Published
  • 29.5 kB
  • 9 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: Chai.ExpectStatic;

    variable fancy

    const fancy: Base<
    Context,
    { skip: { output: unknown; args: [] } } & {
    only: { output: unknown; args: [] };
    } & { retries: { output: unknown; args: any[] } } & {
    catch: {
    output: { error: Error };
    args: [
    arg: string | RegExp | ((err: Error) => any),
    opts?: { raiseIfNotThrown?: boolean | undefined }
    ];
    };
    } & {
    env: {
    output: unknown;
    args: [env: { [k: string]: string }, opts?: EnvOptions];
    };
    } & {
    stub: {
    output: { sandbox: import('sinon').SinonSandbox };
    args: [object: any, path: any, fn: (stub: any) => any];
    };
    } & {
    stdin: {
    output: unknown;
    args: [input: string, delay?: number | undefined];
    };
    } & {
    stderr: {
    output: { readonly stderr: string };
    args: [
    opts?:
    | {
    print?: boolean | undefined;
    stripColor?: boolean | undefined;
    }
    | undefined
    ];
    };
    } & {
    stdout: {
    output: { readonly stdout: string };
    args: [
    opts?:
    | {
    print?: boolean | undefined;
    stripColor?: boolean | undefined;
    }
    | undefined
    ];
    };
    } & {
    nock: {
    output: { nock: number };
    args: [
    host: string,
    options:
    | import('./types').NockOptions
    | import('./types').NockCallback,
    cb?: import('./types').NockCallback | undefined
    ];
    };
    } & {
    timeout: {
    output: { timeout: number };
    args: [timeout?: 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: Record<string, unknown> | 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) => O | Promise<O>) | O | Promise<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 (9)

                                                                                  Dev Dependencies (12)

                                                                                  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>