On this page

    M

    after

    History
    after(fn?, options?): void
    Attributes
    The hook function. If the hook uses callbacks, the callback function is passed as the second argument. Default: A no-op function.
    options:Object
    Configuration options for the hook. The following properties are supported:
    Allows aborting an in-progress hook.
    timeout?:number
    A number of milliseconds the hook will fail after. If unspecified, subtests inherit this value from their parent. Default: Infinity.

    This function creates a hook that runs after executing a suite.

    describe('tests', async () => {
      after(() => console.log('finished running tests'));
      it('is a subtest', () => {
        // Some relevant assertion here
      });
    });

    Note: The after hook is guaranteed to run, even if tests within the suite fail.