Running tests in specific platformsβ
First, let's understand what each definition does:
npx poku
- It tries to identify the platform or run it in Node.js by default.
npx poku --node
- It calls Poku through Node.js and runs all the tests using Node.js.
npx poku --bun
- It calls Poku through Node.js, but runs all the tests using Bun.
npx poku --deno
- It calls Poku through Node.js, but runs all the tests using Deno.
It's important to note that the Poku runtime is different from the test runtime (node
, npx tsx
, bun
, or deno
).
Recommendationsβ
To avoid conflicts in environments with multiple platforms installed (Node.js + Bun, Deno + Bun. etc.), see the following examples:
npx poku --node
- It runs Poku through Node.js and ensures that all tests are run with Node.js (or tsx for TypeScript tests).
bunx poku --bun
- It runs Poku through Bun and ensures that all tests are run with Bun.
deno run npm:poku --deno
- It runs Poku through Deno and ensures that all tests are run with Deno.
For TypeScript users, there's no need to install tsx for Bun and Deno, as they both run TypeScript natively.
Running CommonJS with Denoβ
See all options for Deno here.
All files as CommonJSβ
deno run npm:poku --deno --denoCjs
A specific extension as CommonJSβ
deno run npm:poku --deno --denoCjs='.cjs'
Multiple extensions as CommonJSβ
deno run npm:poku --deno --denoCjs='.cjs,.js'
Using Poku API (advanced concept)β
In Poku's description, you can read "Poku makes testing easy for Node.js, Bun, Deno, and you at the same time", and it's true:
This is more to demonstrate a point, not a recommendation ππ»ββοΈ
./test/run.test.ts:
import { describe, it, poku, exit } from 'poku';
const parallel = true;
const noExit = true;
const codes: (0 | 1)[] = [];
await describe('Running Tests on Different Platforms at the Same Time', async () => {
await Promise.all([
it('Test suite should pass on Node.js', async () => {
const exitCode = await poku(['./test/unit'], {
platform: 'node',
parallel,
noExit,
});
codes.push(exitCode);
}),
it('Test suite should pass on Bun', async () => {
const exitCode = await poku(['./test/unit'], {
platform: 'bun',
parallel,
noExit,
});
codes.push(exitCode);
}),
it('Test suite should pass on Deno', async () => {
const exitCode = await poku(['./test/unit'], {
platform: 'deno',
parallel,
noExit,
deno: {
cjs: ['.cjs'],
},
});
codes.push(exitCode);
}),
]);
});
const code = codes.every((code) => code === 0) ? 0 : 1;
exit(code);
Then, choose a platform:
- Node.js (using TypeScript)
npx tsx test/run.test.ts
- Bun
bun test/run.test.ts
- Deno
deno run test/run.test.ts
It's usually beneficial to have an exclusive CI for each platform, especially to ensure better control in error cases.
If you find any typos, feel free to open a Pull Request correcting them.