t.addRequestHooks Method

Attaches request hooks to the test. Chainable.

t.addRequestHooks(...hooks) → this | Promise<any>
Parameter Type Description
hooks RequestHook subclass A RequestLogger, RequestMock or custom user-defined hook.

Note

The t.addRequestHooks method uses the rest operator that allows you to pass multiple hooks as parameters or arrays of hooks.

Once a request hook is attached, it intercepts HTTP requests sent during the subsequent test actions.

You can also use the test.requestHooks and fixture.requestHooks methods to attach request hooks to an individual test or a fixture. These methods attach hooks before test code starts, so they can handle all HTTP requests the page sends.

Use the t.removeRequestHooks method to remove attached request hooks.