@types/code

  • Version 4.0.8
  • Published
  • 11.5 kB
  • No dependencies
  • MIT license

Install

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

Overview

TypeScript definitions for code

Index

Variables

variable settings

const settings: Settings;
  • Configure code.

Functions

function count

count: () => number;
  • Returns the total number of assertions created using the expect() method.

function expect

expect: <T>(value: T | T[], prefix?: string) => AssertionChain<T>;
  • Generates an assertion object.

function fail

fail: (message: string) => void;
  • Makes the test fail with the given message.

function incomplete

incomplete: () => string[] | null;
  • Returns an array of the locations where incomplete assertions were declared or null if no incomplete assertions found.

function thrownAt

thrownAt: (error?: Error) => CodeError;
  • Returns the filename, line number, and column number of where the error was created.

Interfaces

interface CodeError

interface CodeError {}

    property column

    column: string;

      property filename

      filename: string;

        property line

        line: string;

          interface Flags

          interface Flags<T> {}

            property not

            not: AssertionChain<T>;
            • Inverses the expected result of any assertion

            property once

            once: AssertionChain<T>;
            • Requires that inclusion matches appear only once in the provided value. Used by include().

            property only

            only: AssertionChain<T>;
            • Requires that only the provided elements appear in the provided value. Used by include().

            property part

            part: AssertionChain<T>;
            • Allows a partial match when asserting inclusion Used by include(). Defaults to false.

            property shallow

            shallow: AssertionChain<T>;
            • Performs a comparison using strict equality (===). Code defaults to deep comparison. Used by equal() and include().

            interface Grammar

            interface Grammar<T> {}

              property a

              a: AssertionChain<T>;
              • Connecting word.

              property an

              an: AssertionChain<T>;
              • Connecting word.

              property and

              and: AssertionChain<T>;
              • Connecting word.

              property at

              at: AssertionChain<T>;
              • Connecting word.

              property be

              be: AssertionChain<T>;
              • Connecting word.

              property have

              have: AssertionChain<T>;
              • Connecting word.

              property in

              in: AssertionChain<T>;
              • Connecting word.

              property to

              to: AssertionChain<T>;
              • Connecting word.

              interface Settings

              interface Settings {}

                property comparePrototypes

                comparePrototypes?: boolean | undefined;
                • Ignore object prototypes when doing a deep comparison? Defaults to false.

                property truncateMessages

                truncateMessages?: boolean | undefined;
                • Truncate long assertion error messages for readability? Defaults to true.

                interface Types

                interface Types<T> {}

                  method arguments

                  arguments: () => AssertionChain<T>;
                  • Asserts that the reference value is an arguments object.

                  method array

                  array: () => AssertionChain<T>;
                  • Asserts that the reference value is an Array.

                  method boolean

                  boolean: () => AssertionChain<T>;
                  • Asserts that the reference value is a boolean.

                  method buffer

                  buffer: () => AssertionChain<T>;
                  • Asserts that the reference value is a Buffer.

                  method date

                  date: () => AssertionChain<T>;
                  • Asserts that the reference value is a Date.

                  method error

                  error: (type?: any, message?: string | RegExp) => AssertionChain<T>;
                  • Asserts that the reference value is an error.

                  method function

                  function: () => AssertionChain<T>;
                  • Asserts that the reference value is a function.

                  method number

                  number: () => AssertionChain<T>;
                  • Asserts that the reference value is a number.

                  method object

                  object: () => AssertionChain<T>;
                  • Asserts that the reference value is an object (excluding array, buffer, or other native objects).

                  method regexp

                  regexp: () => AssertionChain<T>;
                  • Asserts that the reference value is a RegExp.

                  method string

                  string: () => AssertionChain<T>;
                  • Asserts that the reference value is a string.

                  interface Values

                  interface Values<T> {}

                    method about

                    about: (value: number, delta: number) => AssertionChain<T>;
                    • Asserts that the reference value is about the provided value within a delta margin of difference.

                    method above

                    above: (value: T) => AssertionChain<T>;
                    • Asserts that the reference value is greater than (>) the provided value.

                    method below

                    below: (value: T) => AssertionChain<T>;
                    • Asserts that the reference value is less than (<) the provided value.

                    method between

                    between: (from: T, to: T) => AssertionChain<T>;
                    • Asserts that the reference value is between but not equal (from < value < to) the provided values.

                    method contain

                    contain: (values: string | string[] | T | T[]) => AssertionChain<T>;
                    • Asserts that the reference value (a string, array, or object) includes the provided values.

                    method contains

                    contains: (values: string | string[] | T | T[]) => AssertionChain<T>;
                    • Asserts that the reference value (a string, array, or object) includes the provided values.

                    method empty

                    empty: () => AssertionChain<T>;
                    • Asserts that the reference value has a length property equal to zero or an object with no keys.

                    method endsWith

                    endsWith: (value: string) => AssertionChain<T>;
                    • Asserts that the reference value (a string) ends with the provided value.

                    method endWith

                    endWith: (value: string) => AssertionChain<T>;
                    • Asserts that the reference value (a string) ends with the provided value.

                    method equal

                    equal: (value: T | T[], options?: any) => AssertionChain<T>;
                    • Asserts that the reference value equals the provided value.

                    method equals

                    equals: (value: T | T[], options?: any) => AssertionChain<T>;
                    • Asserts that the reference value equals the provided value.

                    method exist

                    exist: () => AssertionChain<T>;
                    • Asserts that the reference value exists (not null or undefined).

                    method exists

                    exists: () => AssertionChain<T>;
                    • Asserts that the reference value exists (not null or undefined).

                    method false

                    false: () => AssertionChain<T>;
                    • Asserts that the reference value is false.

                    method greaterThan

                    greaterThan: (value: T) => AssertionChain<T>;
                    • Asserts that the reference value is greater than (>) the provided value.

                    method include

                    include: (values: string | string[] | T | T[]) => AssertionChain<T>;
                    • Asserts that the reference value (a string, array, or object) includes the provided values.

                    method includes

                    includes: (values: string | string[] | T | T[]) => AssertionChain<T>;
                    • Asserts that the reference value (a string, array, or object) includes the provided values.

                    method instanceof

                    instanceof: (type: any) => AssertionChain<T>;
                    • Asserts that the reference value has the provided instanceof value.

                    method instanceOf

                    instanceOf: (type: any) => AssertionChain<T>;
                    • Asserts that the reference value has the provided instanceof value.

                    method least

                    least: (value: T) => AssertionChain<T>;
                    • Asserts that the reference value is at least (>=) the provided value.

                    method length

                    length: (size: number) => AssertionChain<T>;
                    • Asserts that the reference value has a length property matching the provided size or an object with the specified number of keys.

                    method lessThan

                    lessThan: (value: T) => AssertionChain<T>;
                    • Asserts that the reference value is less than (<) the provided value.

                    method match

                    match: (regex: RegExp) => AssertionChain<T>;
                    • Asserts that the reference value's toString() representation matches the provided regular expression.

                    method matches

                    matches: (regex: RegExp) => AssertionChain<T>;
                    • Asserts that the reference value's toString() representation matches the provided regular expression.

                    method max

                    max: (value: T) => AssertionChain<T>;
                    • Asserts that the reference value is at most (<=) the provided value.

                    method min

                    min: (value: T) => AssertionChain<T>;
                    • Asserts that the reference value is at least (>=) the provided value.

                    method most

                    most: (value: T) => AssertionChain<T>;
                    • Asserts that the reference value is at most (<=) the provided value.

                    method null

                    null: () => AssertionChain<T>;
                    • Asserts that the reference value is null.

                    method range

                    range: (from: T, to: T) => AssertionChain<T>;
                    • Asserts that the reference value is within (from <= value <= to) the provided values.

                    method reject

                    reject: (type?: any, message?: string | RegExp) => AssertionChain<T>;
                    • Asserts that the Promise reference value rejects with an exception when called

                    method rejects

                    rejects: (type?: any, message?: string | RegExp) => AssertionChain<T>;
                    • Asserts that the Promise reference value rejects with an exception when called

                    method satisfies

                    satisfies: (validator: (value: T) => boolean) => AssertionChain<T>;
                    • Asserts that the reference value satisfies the provided validator function.

                    method satisfy

                    satisfy: (validator: (value: T) => boolean) => AssertionChain<T>;
                    • Asserts that the reference value satisfies the provided validator function.

                    method startsWith

                    startsWith: (value: string) => AssertionChain<T>;
                    • Asserts that the reference value (a string) starts with the provided value.

                    method startWith

                    startWith: (value: string) => AssertionChain<T>;
                    • Asserts that the reference value (a string) starts with the provided value.

                    method throw

                    throw: (type?: any, message?: string | RegExp) => AssertionChain<T>;
                    • Asserts that the function reference value throws an exception when called.

                    method throws

                    throws: (type?: any, message?: string | RegExp) => AssertionChain<T>;
                    • Asserts that the function reference value throws an exception when called.

                    method true

                    true: () => AssertionChain<T>;
                    • Asserts that the reference value is true.

                    method undefined

                    undefined: () => AssertionChain<T>;
                    • Asserts that the reference value is undefined.

                    method within

                    within: (from: T, to: T) => AssertionChain<T>;
                    • Asserts that the reference value is within (from <= value <= to) the provided values.

                    Type Aliases

                    type Assertion

                    type Assertion<T> = Grammar<T> & Flags<T>;

                      type AssertionChain

                      type AssertionChain<T> = Assertion<T> & Expectation<T>;

                        type Expectation

                        type Expectation<T> = Types<T> & Values<T>;

                          Package Files (1)

                          Dependencies (0)

                          No dependencies.

                          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/code.

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