A ProxySettingSource is a way to calculate the ProxySetting for a given request. It may be a fixed ProxySetting value, or a callback to get ProxySetting values, or an array of sources, which should be iterated to get the first usable value
A reference to a rule parameter defined in the ruleParameters
admin server
option of the corresponding admin server.
Rule parameter references are only valid with a remote client. They can be useful in cases where the admin server has access to local state or APIs that are not accessible from the remote client, but which would be useful in rule definitions. This is only supported for some specific parameters where documented explicitly in that rule parameter.
Generate a CA certificate for mocking HTTPS.
Returns a promise, for an object with key and cert properties, containing the generated private key and certificate in PEM format.
These can be saved to disk, and their paths passed as HTTPS options to a Mockttp server.
Get a Mockttp admin server, which can be used with a Mockttp remote client to create & manage Mockttp instances either from remote machines or from local environments that lack necessary capabilities, e.g. to use Mockttp from inside a browser.
This function exists so you can set up these servers programmatically, but for most
usage you can just run your tests via the mockttp
binary, which will automatically
start and stop an admin server for you:
mockttp -c <your test command>
Get a Mockttp instance on the local machine.
In most simple environments, you can call this method directly and immediately get a Mockttp instance and start mocking servers.
In node, the mocked servers will run in process and require no further setup.
In browsers this is an alias for getRemote. You'll need to start a Mockttp admin server outside your tests before calling this, which will create and manage your fake servers outside the browser.
Get a Mockttp instance, controlled through a Mockttp admin server.
This connects to a Mockttp admin server, and uses that to start and stop mock servers.
Reset a remote admin server, shutting down all Mockttp servers controlled by that
admin server. This is equivalent to calling client.stop()
for all remote
clients of the target server.
This can be useful in some rare cases, where a client might fail to reliably tear down its own server, e.g. in Cypress testing. In this case, it's useful to reset the admin server completely remotely without needing access to any previous client instances, to ensure all servers from previous test runs have been shut down.
After this is called, behaviour of any previously connected clients is undefined, and
it's likely that they may throw errors or experience other undefined behaviour. Ensure
that client.stop()
has been called on all active clients before calling this method.
Generated using TypeDoc
A ProxyConfig is externally provided config that specifies a ProxySettingSource. It might be a ProxySettingSource itself, or it might include references to rule parameters, which must be dereferenced to make it usable as a ProxySettingSource.