ava

  • Version 8.0.0
  • Published
  • 285 kB
  • 40 dependencies
  • MIT license

Install

npm i ava
yarn add ava
pnpm add ava

Overview

Node.js test runner that lets you develop with confidence.

Index

Variables

variable test

const test: TestFn<unknown>;
  • Call to declare a test, or chain to declare hooks or test modifiers

Functions

function registerCompletionHandler

registerCompletionHandler: (handler: () => void) => void;
  • Register a function to be called when AVA has completed a test run without uncaught exceptions or unhandled rejections.

    Completion handlers are invoked in order of registration. Results are not awaited.

Type Aliases

type AfterFn

type AfterFn<Context = unknown> = {
/**
* Declare a hook that is run once, after all tests have passed.
* Additional arguments are passed to the implementation or macro.
*/
<Args extends unknown[]>(
title: string,
implementation: Implementation<Args, Context>,
...args: Args
): void;
/**
* Declare a hook that is run once, after all tests have passed.
* Additional arguments are passed to the implementation or macro.
*/
<Args extends unknown[]>(
implementation: Implementation<Args, Context>,
...args: Args
): void;
always: AlwaysInterface<Context>;
skip: HookSkipFn<Context>;
};

    type AlwaysInterface

    type AlwaysInterface<Context = unknown> = {
    /**
    * Declare a hook that is run once, after all tests are done.
    * Additional arguments are passed to the implementation or macro.
    */
    <Args extends unknown[]>(
    title: string,
    implementation: Implementation<Args, Context>,
    ...args: Args
    ): void;
    /**
    * Declare a hook that is run once, after all tests are done.
    * Additional arguments are passed to the implementation or macro.
    */
    <Args extends unknown[]>(
    implementation: Implementation<Args, Context>,
    ...args: Args
    ): void;
    skip: HookSkipFn<Context>;
    };

      type AssertAssertion

      type AssertAssertion = {
      /**
      * Assert that `actual` is [truthy](https://developer.mozilla.org/en-US/docs/Glossary/Truthy), returning `true` if the
      * assertion passed and throwing otherwise.
      *
      * Note: An `else` clause using this as a type guard will be subtly incorrect for `string` and `number` types and will
      * not give `0` or `''` as a potential value in an `else` clause.
      */
      <T>(actual: T, message?: string): actual is T extends Falsy<T> ? never : T;
      /** Skip this assertion. */
      skip(actual: any, message?: string): void;
      };

        type AssertionError

        type AssertionError = Record<string, unknown> & Error;

          type Assertions

          type Assertions = {
          /**
          * Assert that `actual` is [truthy](https://developer.mozilla.org/en-US/docs/Glossary/Truthy), returning a boolean
          * indicating whether the assertion passed.
          *
          * Note: An `else` clause using this as a type guard will be subtly incorrect for `string` and `number` types and will not give `0` or `''` as a potential value in an `else` clause.
          */
          assert: AssertAssertion;
          /**
          * Assert that `actual` is [deeply equal](https://github.com/concordancejs/concordance#comparison-details) to
          * `expected`, returning a boolean indicating whether the assertion passed.
          */
          deepEqual: DeepEqualAssertion;
          /**
          * Assert that `value` is like `selector`, returning a boolean indicating whether the assertion passed.
          */
          like: LikeAssertion;
          /** Fail the test, always returning `false`. */
          fail: FailAssertion;
          /**
          * Assert that `actual` is strictly false, returning a boolean indicating whether the assertion passed.
          */
          false: FalseAssertion;
          /**
          * Assert that `actual` is [falsy](https://developer.mozilla.org/en-US/docs/Glossary/Falsy), returning a boolean
          * indicating whether the assertion passed.
          */
          falsy: FalsyAssertion;
          /**
          * Assert that `actual` is [the same
          * value](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is) as `expected`,
          * returning a boolean indicating whether the assertion passed.
          */
          is: IsAssertion;
          /**
          * Assert that `actual` is not [the same
          * value](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is) as `expected`,
          * returning a boolean indicating whether the assertion passed.
          */
          not: NotAssertion;
          /**
          * Assert that `actual` is not [deeply equal](https://github.com/concordancejs/concordance#comparison-details) to
          * `expected`, returning a boolean indicating whether the assertion passed.
          */
          notDeepEqual: NotDeepEqualAssertion;
          /**
          * Assert that `string` does not match the regular expression, returning a boolean indicating whether the assertion
          * passed.
          */
          notRegex: NotRegexAssertion;
          /** Assert that the function does not throw. */
          notThrows: NotThrowsAssertion;
          /** Assert that the async function does not throw, or that the promise does not reject. Must be awaited. */
          notThrowsAsync: NotThrowsAsyncAssertion;
          /** Count a passing assertion, always returning `true`. */
          pass: PassAssertion;
          /**
          * Assert that `string` matches the regular expression, returning a boolean indicating whether the assertion passed.
          */
          regex: RegexAssertion;
          /**
          * Assert that `expected` is [deeply equal](https://github.com/concordancejs/concordance#comparison-details) to a
          * previously recorded [snapshot](https://github.com/concordancejs/concordance#serialization-details), or if
          * necessary record a new snapshot.
          */
          snapshot: SnapshotAssertion;
          /**
          * Assert that the function throws a native error. If so, returns the error value.
          */
          throws: ThrowsAssertion;
          /**
          * Assert that the async function throws a native error, or the promise rejects
          * with one. If so, returns a promise for the error value, which must be awaited.
          */
          throwsAsync: ThrowsAsyncAssertion;
          /**
          * Assert that `actual` is strictly true, returning a boolean indicating whether the assertion passed.
          */
          true: TrueAssertion;
          /**
          * Assert that `actual` is [truthy](https://developer.mozilla.org/en-US/docs/Glossary/Truthy), returning a boolean
          * indicating whether the assertion passed.
          *
          * Note: An `else` clause using this as a type guard will be subtly incorrect for `string` and `number` types and will not give `0` or `''` as a potential value in an `else` clause.
          */
          truthy: TruthyAssertion;
          };

            type BeforeFn

            type BeforeFn<Context = unknown> = {
            /**
            * Declare a hook that is run once, before all tests.
            * Additional arguments are passed to the implementation or macro.
            */
            <Args extends unknown[]>(
            title: string,
            implementation: Implementation<Args, Context>,
            ...args: Args
            ): void;
            /**
            * Declare a hook that is run once, before all tests.
            * Additional arguments are passed to the implementation or macro.
            */
            <Args extends unknown[]>(
            implementation: Implementation<Args, Context>,
            ...args: Args
            ): void;
            skip: HookSkipFn<Context>;
            };

              type CommitDiscardOptions

              type CommitDiscardOptions = {
              /**
              * Whether the logs should be included in those of the parent test.
              */
              retainLogs?: boolean;
              };

                type DeepEqualAssertion

                type DeepEqualAssertion = {
                /**
                * Assert that `actual` is [deeply equal](https://github.com/concordancejs/concordance#comparison-details) to
                * `expected`, returning `true` if the assertion passed and throwing otherwise.
                */
                <Actual, Expected extends Actual>(
                actual: Actual,
                expected: Expected,
                message?: string
                ): actual is Expected;
                /**
                * Assert that `actual` is [deeply equal](https://github.com/concordancejs/concordance#comparison-details) to
                * `expected`, returning `true` if the assertion passed and throwing otherwise.
                */
                <Actual extends Expected, Expected>(
                actual: Actual,
                expected: Expected,
                message?: string
                ): expected is Actual;
                /**
                * Assert that `actual` is [deeply equal](https://github.com/concordancejs/concordance#comparison-details) to
                * `expected`, returning `true` if the assertion passed and throwing otherwise.
                */
                <Actual, Expected>(
                actual: Actual,
                expected: Expected,
                message?: string
                ): boolean;
                /** Skip this assertion. */
                skip(actual: any, expected: any, message?: string): void;
                };

                  type ErrorConstructor

                  type ErrorConstructor<ErrorType extends Error = Error> = {
                  readonly prototype: ErrorType;
                  new (...args: any[]): ErrorType;
                  };

                    type ExecutionContext

                    type ExecutionContext<Context = unknown> = {
                    /** Test context, shared with hooks. */
                    context: Context;
                    /** Title of the test or hook. */
                    readonly title: string;
                    /** Whether the test has passed. Only accurate in afterEach hooks. */
                    readonly passed: boolean;
                    readonly log: LogFn;
                    readonly plan: PlanFn;
                    /** Declare a function to be run after the test has ended. */
                    readonly teardown: TeardownFn;
                    readonly timeout: TimeoutFn;
                    readonly try: TryFn<Context>;
                    } & Assertions;
                    • The t value passed to test & hook implementations.

                    type FailAssertion

                    type FailAssertion = {
                    /** Fail the test. */
                    (message?: string): never;
                    /** Skip this assertion. */
                    skip(message?: string): void;
                    };

                      type FailingFn

                      type FailingFn<Context = unknown> = {
                      /**
                      * Declare a concurrent test that is expected to fail.
                      * Additional arguments are passed to the implementation or macro.
                      */
                      <Args extends unknown[]>(
                      title: string,
                      implementation: Implementation<Args, Context>,
                      ...args: Args
                      ): void;
                      /**
                      * Declare a concurrent test, using a macro, that is expected to fail.
                      * Additional arguments are passed to the macro. The macro is responsible for generating a unique test title.
                      */
                      <Args extends unknown[]>(macro: Macro<Args, Context>, ...args: Args): void;
                      only: OnlyFn<Context>;
                      /** Declare a test that only runs when `condition` is true; otherwise the test is skipped. */
                      runIf: RunIfFn<FailingFn<Context>>;
                      skip: SkipFn<Context>;
                      /** Declare a test that is skipped when `condition` is true. */
                      skipIf: SkipIfFn<FailingFn<Context>>;
                      };

                        type FalseAssertion

                        type FalseAssertion = {
                        /**
                        * Assert that `actual` is strictly false, returning `true` if the assertion passed and throwing otherwise.
                        */
                        (actual: any, message?: string): actual is false;
                        /** Skip this assertion. */
                        skip(actual: any, message?: string): void;
                        };

                          type Falsy

                          type Falsy<T> = T extends Exclude<T, FalsyValue>
                          ? T extends number | string | bigint
                          ? T & FalsyValue
                          : never
                          : T;

                            type FalsyAssertion

                            type FalsyAssertion = {
                            /**
                            * Assert that `actual` is [falsy](https://developer.mozilla.org/en-US/docs/Glossary/Falsy), returning `true` if the
                            * assertion passed and throwing otherwise.
                            */
                            <T>(actual: T, message?: string): actual is Falsy<T>;
                            /** Skip this assertion. */
                            skip(actual: any, message?: string): void;
                            };

                              type FalsyValue

                              type FalsyValue = false | 0 | 0n | '' | undefined;

                                type HookSkipFn

                                type HookSkipFn<Context = unknown> = {
                                /** Skip this hook. */
                                <Args extends unknown[]>(
                                title: string,
                                implementation: Implementation<Args, Context>,
                                ...args: Args
                                ): void;
                                /** Skip this hook. */
                                <Args extends unknown[]>(
                                implementation: Implementation<Args, Context>,
                                ...args: Args
                                ): void;
                                };

                                  type Implementation

                                  type Implementation<Args extends unknown[], Context = unknown> =
                                  | ImplementationFn<Args, Context>
                                  | Macro<Args, Context>;
                                  • A test or hook implementation.

                                  type ImplementationFn

                                  type ImplementationFn<Args extends unknown[], Context = unknown> =
                                  | ((t: ExecutionContext<Context>, ...args: Args) => PromiseLike<void>)
                                  | ((t: ExecutionContext<Context>, ...args: Args) => Subscribable)
                                  | ((t: ExecutionContext<Context>, ...args: Args) => void);

                                    type IsAssertion

                                    type IsAssertion = {
                                    /**
                                    * Assert that `actual` is [the same
                                    * value](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is) as `expected`,
                                    * returning `true` if the assertion passed and throwing otherwise.
                                    */
                                    <Actual, Expected extends Actual>(
                                    actual: Actual,
                                    expected: Expected,
                                    message?: string
                                    ): actual is Expected;
                                    /** Skip this assertion. */
                                    skip(actual: any, expected: any, message?: string): void;
                                    };

                                      type LikeAssertion

                                      type LikeAssertion = {
                                      /**
                                      * Assert that `value` is like `selector`, returning `true` if the assertion passed and throwing otherwise.
                                      */
                                      <Expected extends Record<string, any>>(
                                      value: any,
                                      selector: Expected,
                                      message?: string
                                      ): value is Expected;
                                      /** Skip this assertion. */
                                      skip(value: any, selector: any, message?: string): void;
                                      };

                                        type LogFn

                                        type LogFn = {
                                        /** Log one or more values. */
                                        (...values: any[]): void;
                                        /** Skip logging. */
                                        skip(...values: any[]): void;
                                        };

                                          type Macro

                                          type Macro<Args extends unknown[], Context = unknown> = {
                                          /** The function that is executed when the macro is used. */
                                          readonly exec: ImplementationFn<Args, Context>;
                                          /** Generates a test title when this macro is used. */
                                          readonly title?: TitleFn<Args>;
                                          };
                                          • A reusable test or hook implementation.

                                          type MacroDeclarationOptions

                                          type MacroDeclarationOptions<Args extends unknown[], Context = unknown> = {
                                          /** The function that is executed when the macro is used. */
                                          exec: ImplementationFn<Args, Context>;
                                          /** The function responsible for generating a unique title when the macro is used. */
                                          title: TitleFn<Args>;
                                          };

                                            type MacroFn

                                            type MacroFn<Context = unknown> = {
                                            /** Declare a reusable test implementation. */
                                            <Args extends unknown[]>(
                                            /** The function that is executed when the macro is used. */ exec: ImplementationFn<
                                            Args,
                                            Context
                                            >
                                            ): Macro<Args, Context>;
                                            <Args extends unknown[]>(
                                            declaration: MacroDeclarationOptions<Args, Context>
                                            ): Macro<Args, Context>;
                                            };

                                              type Meta

                                              type Meta = {
                                              /** Path to the test file being executed. */
                                              file: string;
                                              /** Directory where snapshots are stored. */
                                              snapshotDirectory: string;
                                              };

                                                type NotAssertion

                                                type NotAssertion = {
                                                /**
                                                * Assert that `actual` is not [the same
                                                * value](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is) as `expected`,
                                                * returning `true` if the assertion passed and throwing otherwise.
                                                */
                                                <Actual, Expected>(actual: Actual, expected: Expected, message?: string): true;
                                                /** Skip this assertion. */
                                                skip(actual: any, expected: any, message?: string): void;
                                                };

                                                  type NotDeepEqualAssertion

                                                  type NotDeepEqualAssertion = {
                                                  /**
                                                  * Assert that `actual` is not [deeply equal](https://github.com/concordancejs/concordance#comparison-details) to
                                                  * `expected`, returning `true` if the assertion passed and throwing otherwise.
                                                  */
                                                  <Actual, Expected>(actual: Actual, expected: Expected, message?: string): true;
                                                  /** Skip this assertion. */
                                                  skip(actual: any, expected: any, message?: string): void;
                                                  };

                                                    type NotRegexAssertion

                                                    type NotRegexAssertion = {
                                                    /**
                                                    * Assert that `string` does not match the regular expression, returning `true` if the assertion passed and throwing
                                                    * otherwise.
                                                    */
                                                    (string: string, regex: RegExp, message?: string): true;
                                                    /** Skip this assertion. */
                                                    skip(string: string, regex: RegExp, message?: string): void;
                                                    };

                                                      type NotThrowsAssertion

                                                      type NotThrowsAssertion = {
                                                      /**
                                                      * Assert that the function does not throw, returning `true` if the assertion passed and throwing otherwise.
                                                      */
                                                      (fn: () => any, message?: string): true;
                                                      /** Skip this assertion. */
                                                      skip(fn: () => any, message?: string): void;
                                                      };

                                                        type NotThrowsAsyncAssertion

                                                        type NotThrowsAsyncAssertion = {
                                                        /**
                                                        * Assert that the async function does not throw, returning a promise for `true` if the assertion passesd and a
                                                        * rejected promise otherwise.
                                                        *
                                                        * You must await the result.
                                                        */
                                                        (fn: () => PromiseLike<any>, message?: string): Promise<true>;
                                                        /** Assert that the promise does not reject, returning a promise for `true` if the assertion passesd and a
                                                        * rejected promise otherwise.
                                                        *
                                                        * You must await the result.
                                                        */
                                                        (promise: PromiseLike<any>, message?: string): Promise<true>;
                                                        /** Skip this assertion. */
                                                        skip(nonThrower: any, message?: string): void;
                                                        };

                                                          type OnlyFn

                                                          type OnlyFn<Context = unknown> = {
                                                          /**
                                                          * Declare a test. Only this test and others declared with `.only()` are run.
                                                          * Additional arguments are passed to the implementation or macro.
                                                          */
                                                          <Args extends unknown[]>(
                                                          title: string,
                                                          implementation: Implementation<Args, Context>,
                                                          ...args: Args
                                                          ): void;
                                                          /**
                                                          * Declare a test that uses a macro. Only this test and others declared with `.only()` are run.
                                                          * Additional arguments are passed to the macro. The macro is responsible for generating a unique test title.
                                                          */
                                                          <Args extends unknown[]>(macro: Macro<Args, Context>, ...args: Args): void;
                                                          };

                                                            type PassAssertion

                                                            type PassAssertion = {
                                                            /** Count a passing assertion, always returning `true`. */
                                                            (message?: string): true;
                                                            /** Skip this assertion. */
                                                            skip(message?: string): void;
                                                            };

                                                              type PlanFn

                                                              type PlanFn = {
                                                              /**
                                                              * Plan how many assertion there are in the test. The test will fail if the actual assertion count doesn't match the
                                                              * number of planned assertions. See [assertion planning](https://github.com/avajs/ava#assertion-planning).
                                                              */
                                                              (count: number): void;
                                                              /** Don't plan assertions. */
                                                              skip(count: number): void;
                                                              };

                                                                type RegexAssertion

                                                                type RegexAssertion = {
                                                                /**
                                                                * Assert that `string` matches the regular expression, returning `true` if the assertion passed and throwing
                                                                * otherwise.
                                                                */
                                                                (string: string, regex: RegExp, message?: string): true;
                                                                /** Skip this assertion. */
                                                                skip(string: string, regex: RegExp, message?: string): void;
                                                                };

                                                                  type RunIfFn

                                                                  type RunIfFn<Chain> = (condition: boolean) => Chain;
                                                                  • Declare a test that only runs when condition is true; otherwise the test is skipped.

                                                                  type SerialFn

                                                                  type SerialFn<Context = unknown> = {
                                                                  /** Declare a serial test. Additional arguments are passed to the implementation or macro. */
                                                                  <Args extends unknown[]>(
                                                                  title: string,
                                                                  implementation: Implementation<Args, Context>,
                                                                  ...args: Args
                                                                  ): void;
                                                                  /**
                                                                  * Declare a serial test that uses a macro. The macro is responsible for generating a unique test title.
                                                                  */
                                                                  <Args extends unknown[]>(macro: Macro<Args, Context>, ...args: Args): void;
                                                                  after: AfterFn<Context>;
                                                                  afterEach: AfterFn<Context>;
                                                                  before: BeforeFn<Context>;
                                                                  beforeEach: BeforeFn<Context>;
                                                                  failing: FailingFn<Context>;
                                                                  only: OnlyFn<Context>;
                                                                  /** Declare a test that only runs when `condition` is true; otherwise the test is skipped. */
                                                                  runIf: RunIfFn<SerialFn<Context>>;
                                                                  skip: SkipFn<Context>;
                                                                  /** Declare a test that is skipped when `condition` is true. */
                                                                  skipIf: SkipIfFn<SerialFn<Context>>;
                                                                  /** Declare a test that should be implemented later. */
                                                                  todo: TodoFn;
                                                                  };

                                                                    type SkipFn

                                                                    type SkipFn<Context = unknown> = {
                                                                    /** Skip this test. */
                                                                    <Args extends unknown[]>(
                                                                    title: string,
                                                                    implementation: Implementation<Args, Context>,
                                                                    ...args: Args
                                                                    ): void;
                                                                    /** Skip this test. */
                                                                    <Args extends unknown[]>(macro: Macro<Args, Context>, ...args: Args): void;
                                                                    };

                                                                      type SkipIfFn

                                                                      type SkipIfFn<Chain> = (condition: boolean) => Chain;
                                                                      • Declare a test that is skipped when condition is true.

                                                                      type SnapshotAssertion

                                                                      type SnapshotAssertion = {
                                                                      /**
                                                                      * Assert that `expected` is [deeply equal](https://github.com/concordancejs/concordance#comparison-details) to a
                                                                      * previously recorded [snapshot](https://github.com/concordancejs/concordance#serialization-details), or if
                                                                      * necessary record a new snapshot.
                                                                      *
                                                                      * Returns `true` if the assertion passed and throws otherwise.
                                                                      */
                                                                      (expected: any, message?: string): true;
                                                                      /** Skip this assertion. */
                                                                      skip(expected: any, message?: string): void;
                                                                      };

                                                                        type Subscribable

                                                                        type Subscribable = {
                                                                        subscribe(observer: { error(error: any): void; complete(): void }): void;
                                                                        };

                                                                          type TeardownFn

                                                                          type TeardownFn = (fn: (() => Promise<void>) | (() => void)) => void;
                                                                          • Declare a function to be run after the test has ended.

                                                                          type TestFn

                                                                          type TestFn<Context = unknown> = {
                                                                          /** Declare a concurrent test. Additional arguments are passed to the implementation or macro. */
                                                                          <Args extends unknown[]>(
                                                                          title: string,
                                                                          implementation: Implementation<Args, Context>,
                                                                          ...args: Args
                                                                          ): void;
                                                                          /**
                                                                          * Declare a concurrent test that uses a macro. Additional arguments are passed to the macro.
                                                                          * The macro is responsible for generating a unique test title.
                                                                          */
                                                                          <Args extends unknown[]>(macro: Macro<Args, Context>, ...args: Args): void;
                                                                          after: AfterFn<Context>;
                                                                          afterEach: AfterFn<Context>;
                                                                          before: BeforeFn<Context>;
                                                                          beforeEach: BeforeFn<Context>;
                                                                          failing: FailingFn<Context>;
                                                                          macro: MacroFn<Context>;
                                                                          meta: Meta;
                                                                          only: OnlyFn<Context>;
                                                                          /** Declare a test that only runs when `condition` is true; otherwise the test is skipped. */
                                                                          runIf: RunIfFn<TestFn<Context>>;
                                                                          serial: SerialFn<Context>;
                                                                          skip: SkipFn<Context>;
                                                                          /** Declare a test that is skipped when `condition` is true. */
                                                                          skipIf: SkipIfFn<TestFn<Context>>;
                                                                          /** Declare a test that should be implemented later. */
                                                                          todo: TodoFn;
                                                                          };

                                                                            type ThrownError

                                                                            type ThrownError<ErrorType extends ErrorConstructor | Error> =
                                                                            ErrorType extends ErrorConstructor ? ErrorType['prototype'] : ErrorType;

                                                                              type ThrowsAnyExpectation

                                                                              type ThrowsAnyExpectation = Omit<
                                                                              ThrowsExpectation<any>,
                                                                              'any' | 'instanceOf' | 'is'
                                                                              > & {
                                                                              /** If true, the thrown error is not required to be a native error. */
                                                                              any: true;
                                                                              /** The thrown error must be an instance of this constructor. */
                                                                              instanceOf?: new (...args: any[]) => any;
                                                                              /** The thrown error must be strictly equal to this value. */
                                                                              is?: any;
                                                                              };

                                                                                type ThrowsAssertion

                                                                                type ThrowsAssertion = {
                                                                                /**
                                                                                * Assert that the function throws a native error. The error must satisfy all expectations. Returns the error value if
                                                                                * the assertion passes and throws otherwise.
                                                                                */
                                                                                <ErrorType extends ErrorConstructor | Error>(
                                                                                fn: () => any,
                                                                                expectations?: ThrowsExpectation<ErrorType>,
                                                                                message?: string
                                                                                ): ThrownError<ErrorType>;
                                                                                /**
                                                                                * Assert that the function throws. The error must satisfy all expectations. Returns the error value if the assertion
                                                                                * passes and throws otherwise.
                                                                                */
                                                                                (fn: () => any, expectations?: ThrowsAnyExpectation, message?: string): unknown;
                                                                                /** Skip this assertion. */
                                                                                skip(fn: () => any, expectations?: any, message?: string): void;
                                                                                };

                                                                                  type ThrowsAsyncAssertion

                                                                                  type ThrowsAsyncAssertion = {
                                                                                  /**
                                                                                  * Assert that the async function throws a native error. You must await the result. The error must satisfy all
                                                                                  * expectations. Returns a promise for the error value if the assertion passes and a rejected promise otherwise.
                                                                                  */
                                                                                  <ErrorType extends ErrorConstructor | Error>(
                                                                                  fn: () => PromiseLike<any>,
                                                                                  expectations?: ThrowsExpectation<ErrorType>,
                                                                                  message?: string
                                                                                  ): Promise<ThrownError<ErrorType>>;
                                                                                  /**
                                                                                  * Assert that the promise rejects with a native error. You must await the result. The error must satisfy all
                                                                                  * expectations. Returns a promise for the error value if the assertion passes and a rejected promise otherwise.
                                                                                  */
                                                                                  <ErrorType extends ErrorConstructor | Error>(
                                                                                  promise: PromiseLike<any>,
                                                                                  expectations?: ThrowsExpectation<ErrorType>,
                                                                                  message?: string
                                                                                  ): Promise<ThrownError<ErrorType>>;
                                                                                  /**
                                                                                  * Assert that the async function throws. You must await the result. The error must satisfy all expectations. Returns
                                                                                  * a promise for the error value if the assertion passes and a rejected promise otherwise.
                                                                                  */
                                                                                  (
                                                                                  fn: () => PromiseLike<any>,
                                                                                  expectations?: ThrowsAnyExpectation,
                                                                                  message?: string
                                                                                  ): Promise<unknown>;
                                                                                  /**
                                                                                  * Assert that the promise rejects. You must await the result. The error must satisfy all expectations. Returns a
                                                                                  * promise for the error value if the assertion passes and a rejected promise otherwise.
                                                                                  */
                                                                                  (
                                                                                  promise: PromiseLike<any>,
                                                                                  expectations?: ThrowsAnyExpectation,
                                                                                  message?: string
                                                                                  ): Promise<unknown>;
                                                                                  /** Skip this assertion. */
                                                                                  skip(thrower: any, expectations?: any, message?: string): void;
                                                                                  };

                                                                                    type ThrowsExpectation

                                                                                    type ThrowsExpectation<ErrorType extends ErrorConstructor | Error> = {
                                                                                    /** If true, the thrown error is not required to be a native error. */
                                                                                    any?: false;
                                                                                    /** The thrown error must have a code that equals the given string or number. */
                                                                                    code?: string | number;
                                                                                    /** The thrown error must be an instance of this constructor. */
                                                                                    instanceOf?: ErrorType extends ErrorConstructor
                                                                                    ? ErrorType
                                                                                    : ErrorType extends Error
                                                                                    ? ErrorConstructor<ErrorType>
                                                                                    : never;
                                                                                    /** The thrown error must be strictly equal to this value. */
                                                                                    is?: ErrorType extends ErrorConstructor ? ErrorType['prototype'] : ErrorType;
                                                                                    /** The thrown error must have a message that equals the given string, or matches the regular expression. */
                                                                                    message?: string | RegExp | ((message: string) => boolean);
                                                                                    /** The thrown error must have a name that equals the given string. */
                                                                                    name?: string;
                                                                                    };
                                                                                    • Specify one or more expectations the thrown error must satisfy.

                                                                                    type TimeoutFn

                                                                                    type TimeoutFn = {
                                                                                    /**
                                                                                    * Set a timeout for the test, in milliseconds. The test will fail if the timeout is exceeded.
                                                                                    * The timeout is reset each time an assertion is made.
                                                                                    */
                                                                                    (ms: number, message?: string): void;
                                                                                    /** Clear the timeout and restore the default behavior. */
                                                                                    clear(): void;
                                                                                    };

                                                                                      type TitleFn

                                                                                      type TitleFn<Args extends unknown[]> = (
                                                                                      providedTitle: string | undefined,
                                                                                      ...args: Args
                                                                                      ) => string;

                                                                                        type TodoFn

                                                                                        type TodoFn = (title: string) => void;
                                                                                        • Declare a test that should be implemented later.

                                                                                        type TrueAssertion

                                                                                        type TrueAssertion = {
                                                                                        /**
                                                                                        * Assert that `actual` is strictly true, returning `true` if the assertion passed and throwing otherwise.
                                                                                        */
                                                                                        (actual: any, message?: string): actual is true;
                                                                                        /** Skip this assertion. */
                                                                                        skip(actual: any, message?: string): void;
                                                                                        };

                                                                                          type TruthyAssertion

                                                                                          type TruthyAssertion = {
                                                                                          /**
                                                                                          * Assert that `actual` is [truthy](https://developer.mozilla.org/en-US/docs/Glossary/Truthy), returning `true` if the
                                                                                          * assertion passed and throwing otherwise.
                                                                                          *
                                                                                          * Note: An `else` clause using this as a type guard will be subtly incorrect for `string` and `number` types and will
                                                                                          * not give `0` or `''` as a potential value in an `else` clause.
                                                                                          */
                                                                                          <T>(actual: T, message?: string): actual is T extends Falsy<T> ? never : T;
                                                                                          /** Skip this assertion. */
                                                                                          skip(actual: any, message?: string): void;
                                                                                          };

                                                                                            type TryFn

                                                                                            type TryFn<Context = unknown> = {
                                                                                            /**
                                                                                            * Attempt to run some assertions. The result must be explicitly committed or discarded or else
                                                                                            * the test will fail. The title may help distinguish attempts from one another.
                                                                                            */
                                                                                            <Args extends unknown[]>(
                                                                                            title: string,
                                                                                            fn: Implementation<Args, Context>,
                                                                                            ...args: Args
                                                                                            ): Promise<TryResult>;
                                                                                            /**
                                                                                            * Attempt to run some assertions. The result must be explicitly committed or discarded or else
                                                                                            * the test will fail.
                                                                                            */
                                                                                            <Args extends unknown[]>(
                                                                                            fn: Implementation<Args, Context>,
                                                                                            ...args: Args
                                                                                            ): Promise<TryResult>;
                                                                                            };

                                                                                              type TryResult

                                                                                              type TryResult = {
                                                                                              /**
                                                                                              * Title of the attempt, helping you tell attempts aparts.
                                                                                              */
                                                                                              title: string;
                                                                                              /**
                                                                                              * Indicates whether all assertions passed, or at least one failed.
                                                                                              */
                                                                                              passed: boolean;
                                                                                              /**
                                                                                              * Errors raised for each failed assertion.
                                                                                              */
                                                                                              errors: AssertionError[];
                                                                                              /**
                                                                                              * Logs created during the attempt using `t.log()`. Contains formatted values.
                                                                                              */
                                                                                              logs: string[];
                                                                                              /**
                                                                                              * Commit the attempt. Counts as one assertion for the plan count. If the
                                                                                              * attempt failed, calling this will also cause your test to fail.
                                                                                              */
                                                                                              commit(options?: CommitDiscardOptions): void;
                                                                                              /**
                                                                                              * Discard the attempt.
                                                                                              */
                                                                                              discard(options?: CommitDiscardOptions): void;
                                                                                              };

                                                                                                Package Files (6)

                                                                                                Dependencies (40)

                                                                                                Dev Dependencies (15)

                                                                                                Peer Dependencies (1)

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

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