=============== LIBRARY RULES =============== From library maintainers: - Use the scoped packages @zimic/http, @zimic/fetch, and @zimic/interceptor. - @zimic/interceptor: In createHttpInterceptor, `type` is optional and defaults to 'local'. Only set `type: 'remote'` when using an interceptor server. - @zimic/interceptor: Local interceptor methods are synchronous: interceptor.clear(), interceptor.checkTimes(), and handler.with()/respond()/times()/checkTimes() return values directly. - @zimic/interceptor: Remote interceptor methods return promises: await interceptor.clear(), interceptor.checkTimes(), and every handler chain before making requests. - @zimic/interceptor: Remote interceptors need a running server, usually started as `zimic-interceptor server start --port --ephemeral -- `. Their unhandled requests can only be rejected, not bypassed. - @zimic/interceptor: Local interceptors in browsers require `zimic-interceptor browser init ` before interceptor.start(). - @zimic/interceptor: handler.with() matches partially by default. Use `exact: true` only when extra headers, search params, or body fields must cause a mismatch. - @zimic/fetch: The package follows the Fetch API: JSON request bodies must be serialized with JSON.stringify and sent with an explicit `content-type: application/json` header. Schema content-type inference affects types only. - @zimic/fetch: The package does not throw on non-2xx responses. Check response.ok, throw response.error when needed, and narrow caught errors with fetch.isResponseError(error, method, path). - @zimic/http, @zimic/fetch, @zimic/interceptor: Declare path params in schema keys as '/users/:userId'. When calling fetch, pass the concrete path, such as `/users/${id}`. ### createInterceptorServer usage example Source: https://github.com/zimicjs/zimic/blob/main/apps/zimic-web/docs/zimic-interceptor/api/4-create-interceptor-server.md Example of creating and starting an interceptor server, running a command, and stopping the server. The highlighted lines show the createInterceptorServer call with hostname and port options. ```typescript import { spawn, SpawnOptions } from 'child_process'; import { createInterceptorServer } from '@zimic/interceptor/server'; async function runCommand(commandEntry: string, commandArguments: string[], options: SpawnOptions) { await new Promise((resolve, reject) => { const commandProcess = spawn(commandEntry, commandArguments, options); commandProcess.once('error', (error) => { reject(error); }); commandProcess.once('close', (code) => { if (code === 0) { resolve(); } else { reject(new Error(`Command '${commandEntry}' exited with code ${code}`)); } }); }); } // highlight-start const server = createInterceptorServer({ hostname: 'localhost', port: 3000, }); // highlight-end await server.start(); // Run a command when the server is ready, assuming the following format: // node