Interface: FpApi
Definido em: fp-api.d.ts:488
The Fetchpier scripting API — the only global exposed to pre-request and
post-response scripts besides console and a whitelisted subset of
ECMAScript built-ins.
Available in two phases:
- pre-request (runs before the HTTP fetch):
fp.requestis mutable,fp.responseisundefined. - post-response (runs after the fetch):
fp.responseis available, mutations tofp.requestthrow.
Propriedades
Section titled “Propriedades”environment
Section titled “environment”readonly environment: FpEnvironment;Definido em: fp-api.d.ts:496
Persistent environment variables for the active environment.
request
Section titled “request”readonly request: FpRequest;Definido em: fp-api.d.ts:490
The outgoing HTTP request. Mutable in pre-request, read-only in post-response.
response?
Section titled “response?”readonly optional response?: FpResponse;Definido em: fp-api.d.ts:493
The HTTP response. Only defined in post-response scripts.
variables
Section titled “variables”readonly variables: FpVariables;Definido em: fp-api.d.ts:499
Ephemeral per-request variables shared between pre and post phases.
Métodos
Section titled “Métodos”error()
Section titled “error()”error(...args): void;Definido em: fp-api.d.ts:532
Logs to the Scripts console at the error level.
Parameters
Section titled “Parameters”| Parameter | Tipo |
|---|---|
…args | unknown[] |
Retorna
Section titled “Retorna”void
expect()
Section titled “expect()”expect(value): ChaiExpect;Definido em: fp-api.d.ts:523
Starts a fluent chai-like assertion on value.
Parameters
Section titled “Parameters”| Parameter | Tipo |
|---|---|
value | unknown |
Retorna
Section titled “Retorna”Example
Section titled “Example”fp.expect(user).to.have.property('email').that.is.a('string')log(...args): void;Definido em: fp-api.d.ts:526
Logs to the Scripts console at the log level.
Parameters
Section titled “Parameters”| Parameter | Tipo |
|---|---|
…args | unknown[] |
Retorna
Section titled “Retorna”void
test()
Section titled “test()”test(name, fn): void;Definido em: fp-api.d.ts:515
Defines a named test. The callback must be synchronous; any error thrown
(including fp.expect failures) marks the test as failed.
The result is surfaced in the Tests tab of the request pane.
Parameters
Section titled “Parameters”| Parameter | Tipo | Descrição |
|---|---|---|
name | string | Human-readable test name shown in the UI. |
fn | () => void | Synchronous assertion block. |
Retorna
Section titled “Retorna”void
Example
Section titled “Example”fp.test('status is 200', () => { fp.expect(fp.response.status).to.equal(200)})warn()
Section titled “warn()”warn(...args): void;Definido em: fp-api.d.ts:529
Logs to the Scripts console at the warn level.
Parameters
Section titled “Parameters”| Parameter | Tipo |
|---|---|
…args | unknown[] |
Retorna
Section titled “Retorna”void