Skip to main content
Version: v2.x.x

Mock using ESM

You can use your favorite Mock framework or tool and Poku together πŸ·βž•

By not locking you into a specific set of plugins or mocking/spying tools, Poku promotes an open ecosystem where developers are free to integrate the tools that best suit their needs.

For this example, let's use the quibble, then testing its results with Poku:

import { assert } from 'poku';
import quibble from 'quibble';

await quibble.esm('../lib/funds.js', {
// Original: 100
getFunds: () => 200,
});

const { withdraw } = await import('../lib/withdraw.test.js');

assert.strictEqual(withdraw(200), true, 'Mocking my funds to 200');

assert.strictEqual(withdraw(300), false, "I can't get more than I have");

await quibble.reset();

Then:

npx poku