Test.requestHooks Method

Attaches the request hooks to the test.

test.requestHooks(...hooks) → this
Parameter Type Description
hooks RequestHook subclass A RequestLogger, RequestMock or custom user-defined hook.

Note

The test.requestHooks method uses the rest operator which allows you to pass multiple hooks as parameters or arrays of hooks.

Request hooks attached to a test intercept HTTP requests sent during its execution.

You can also use the fixture.requestHooks method to attach request hooks to a fixture. These hooks handle HTTP requests in all tests in this fixture.

Note

Request hooks attached to a fixture are invoked before hooks attached to its tests.

The t.addRequestHooks method allows you to attach request hooks throughout test execution.

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