Simple mocks (extracted from unjs/unenv).
Main usage of mocked-exports is to use them as bundler aliases to mock specific modules you don't want to end-up into your bundle.
// Exports a dynamic mock proxy function
const proxy = require("mocked-exports/proxy");
import proxy from "mocked-exports/proxy";
import proxy from "mocked-exports/proxy/foo/bar/baz";
// Exports a no-op frozen function
const noop = require("mocked-exports/noop");
import noop from "mocked-exports/noop";
// Exports an empty frozen object
const empty = require("mocked-exports/empty");
import empty from "mocked-exports/empty";There are also extra variants of exports with -mjs or -cjs suffixes available if your mocking needs to force a specific format.
The proxy mock, is a nested deep proxy that tries to replace any dynamic nested access to an unknown object.
Examples: proxy.foo.bar().xyz[1].then(() => {});
For better debugging, you can use proxy.__mock__('name') to create a named instance.
local development
Published under the MIT license.
Made by community 💛
🤖 auto updated with automd