FireWyrm provides lightweight object method mocking viaDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/michael-tiger-2010/wyvernjs/llms.txt
Use this file to discover all available pages before exploring further.
fw.mock(). It replaces a named property on any object with a stub function, records the original value internally, and lets you restore everything in one call when the tests are finished. Mocking is useful for intercepting network calls, neutralising side-effectful functions like console.log, or making timers and other browser APIs behave predictably during a test run — all without any external library.
fw.mock(fn)
Creates a mock descriptor. fn is the replacement function to install. If fn is omitted, a no-op (() => {}) is used.
Returns an object with a single method: .replace(obj, prop).
.replace(obj, prop)
Swaps obj[prop] for the stub function supplied to fw.mock(). The original value is saved so it can be restored later. Returns the internal mock record (not fw) — further chaining is not typical here.
fw.mock.restore(select?)
Restores mocked properties to their original values. By default it restores all active mocks. Pass a property name string to restore only that specific replacement.
restore() is called, the internal mocks list is cleared.
Full example
The pattern below shows the complete lifecycle: mock before the tests that depend on it, run the tests, then restore everything inside thefw.end() callback.
FireWyrm mocking is intentionally minimal — it replaces properties on
existing objects, not module-level imports. If you need to intercept ES
module imports (e.g.
import { fetchJson } from './api.js') in a bundler
environment, use your bundler’s own mock facilities (such as Vite’s
vi.mock() or webpack’s jest.mock()) alongside FireWyrm’s assertion layer.