@pokujs/shared-resources
v1.1.0
Published
šŖ¢ A Poku plugin for shared resources across isolated tests.
Downloads
512
Maintainers
Readme
@pokujs/shared-resources
Enjoying Poku? Give him a star to show your support š
š Documentation
šŖ¢ @pokujs/shared-resources is a Poku plugin for shared resources across isolated tests.
[!TIP]
Share state, servers, database connections, and more between parallel test files ā no duplicated setup, no conflicts.
Quickstart
Install
# Node.js
npm i -D @pokujs/shared-resources# Bun
bun add -d @pokujs/shared-resources# Deno (optional)
deno add npm:@pokujs/shared-resourcesEnable the Plugin
// poku.config.js
import { sharedResources } from '@pokujs/shared-resources';
import { defineConfig } from 'poku';
export default defineConfig({
plugins: [sharedResources()],
});Define a Shared Resource
// resources/counter.js
import { resource } from '@pokujs/shared-resources';
export const Counter = resource.create(() => ({
count: 0,
increment() {
this.count++;
return this.count;
},
getCount() {
return this.count;
},
}));Use in Your Tests
// tests/my-test.test.js
import { resource } from '@pokujs/shared-resources';
import { assert, test } from 'poku';
import { Counter } from '../resources/counter.js';
test('Shared Counter', async () => {
const counter = await resource.use(Counter);
await counter.increment();
assert.strictEqual(await counter.getCount(), 1);
});