Understand Mockttp setup modes: getLocal, getRemote, and getAdminServer
mainMockttp provides three primary ways to instantiate a client, depending on your environment and whether the mock server is running in-process or remotely:
getLocal(): Returns a Mockttp instance using a local in-process mock server. In Node.js, this automatically manages server lifecycle. In a browser, this is an alias forgetRemote().getRemote(): Returns a Mockttp instance that communicates with a separate admin server to configure a remote mock server. This is required for browser-based testing (since browsers cannot host HTTP servers) and is useful for testing mobile/IoT devices on a network.getAdminServer(): Returns an admin server (Node.js only) that allows remote clients to start, stop, and configure multiple mock servers. You can run this via the CLI helpermockttp -c [test command]to automate lifecycle management.
const mockServer = require('mockttp').getLocal();
const adminServer = require('mockttp').getAdminServer();