replace-fetch-request

Check that the replace-fetch-request snippet is working as expected.

Body in init

Test that a string in a fetch request body passed via the init object is replaced with the given replacement value.

Example Content
Waiting 500ms to trigger snippet...
fetch request body was replaced

Steps

Filters

Body on a Request

Test that a string in the body of a Request object passed to fetch is replaced with the given replacement value. The body of a Request can only be read asynchronously, so it is cloned, rewritten and the Request is rebuilt before the request is sent.

Example Content
Waiting 500ms to trigger snippet...
fetch request body was replaced

Steps

Filters

Regex

Test that a regex pattern in the request body is replaced with the given replacement value.

Example Content
Waiting 500ms to trigger snippet...
fetch request body was replaced

Steps

Filters

Needle

Test that replacement only happens when the needle matches the request body.

Example Content
Waiting 500ms to trigger snippet...
fetch request body was replaced

Steps

Filters

JSONPath

Test that a JSONPath expression targets and replaces a nested property in the request body.

Example Content
Waiting 500ms to trigger snippet...
fetch request body was replaced

Steps

Filters

JSONPath append

Test that JSONPath append mode pushes a value into an existing array in the request body.

Example Content
Waiting 500ms to trigger snippet...
fetch request body was replaced

Steps

Filters