Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

poku

Package Overview
Dependencies
Maintainers
1
Versions
83
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

poku

🐷 Poku is a flexible and easy-to-use Test Runner for Node.js, Bun and Deno that allows you to run parallel and sequential tests, plus high isolation level per test file

  • 1.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
369
decreased by-20.99%
Maintainers
1
Weekly downloads
 
Created
Source

Poku

Logo

A flexible and easy-to-use Test Runner for Node.js, Bun and Deno that allows you to run parallel and sequential tests, plus high isolation level per test file.

Node.js Version Bun Version Deno Version NPM Version License GitHub Workflow Status (with event) GitHub Workflow Status (with event)


Why Poku?

Poku starts from the premise where tests come to help, not overcomplicate: runs test files in an individual process per file, shows progress and exits 🧙🏻

  • Supports ESM and CJS
  • Designed to be highly intuitive
  • No need to compile TypeScript
  • Compatible with Coverage tools
  • Allows both in-code and CLI usage
  • Zero configurations, except you want
  • No constraints or rules, code in your own signature style

  • Totally dependency-free
  • Poku dive to the deepest depths to find tests in the specified directories
  • Compatibility: Poku is tested across all Node 6+, Bun 0.5.3+ and Deno 1.30+ versions
  • Poku uses itself to test its own tests using process.exit at several depths on the same process node

  npx poku --include='test/unit,test/integration'

Install

Node.js

npm install --save-dev poku

TypeScript (Node.js)

npm install --save-dev poku tsx

Bun

bun add --dev poku

Deno

import { poku } from 'npm:poku';
  • Poku requires these permissions by default: --allow-read, --allow-env and --allow-run.

Basic Usage

In-code

import { poku } from 'poku';

await poku(['./a', './b']);
import { poku } from 'npm:poku';

await poku(['./a', './b']);

CLI

npx poku --include='./a,./b'
bun poku --include='./a,./b'
deno run npm:poku --include='./a,./b'

Documentation

Website in Progress 🧑🏻‍🔧

Initially, the documentation is based on Node.js usage, but you can use all the options normally for both Bun and Deno.

poku(targetDirs: string | string[])

Include directories
poku('./targetDir');
poku(['./targetDirA', './targetDirB']);
npx poku --include='./targetDir'
npx poku --include='./targetDirA,./targetDirB'

poku(targetDirs: string | string[], configs?: Configs)

parallel: boolean

Determines the mode of test execution across sequential or parallel modes.

  • in-code
/**
 * @default
 *
 * Sequential mode
 */

poku(['...'], {
  parallel: false,
});
/**
 * Parallel mode
 */

poku(['...'], {
  parallel: true,
});
  • CLI

Since 1.2.0

# Parallel mode

npx poku --include='...' --parallel

platform: "node" | "bun" | "deno"

Since 1.2.0

By default, Poku tries to identify the platform automatically, but you can set it manually:

  • in-code
/**
 * Force Node.js (or tsx for TypeScript)
 *
 * @default 'node'
 */

poku('...', {
  platform: 'node',
});
/**
 * Force Bun
 */

poku('...', {
  platform: 'bun',
});
/**
 * Force Deno
 */

poku('...', {
  platform: 'deno',
});
  • CLI
# Normal

npx poku   --include='...' --platform=node
bun poku   --include='...' --platform=bun
deno poku  --include='...' --platform=deno
# Custom

npx poku       --include='...' --platform=bun
bun poku       --include='...' --platform=deno
deno run poku  --include='...' --platform=node
# ...

filter: RexExp

By default, Poku searches for .test. files, but you can customize it using the filter option.

Filter by path using Regex to match only the files that should be performed.

  • in-code
/**
 * @default
 *
 * Testing all `*.test.*` files.
 */

poku(['...'], {
  filter: /\.test\./,
});
/**
 * Testing all `ts`, `js`, `mts` and `mjs` files
 */

poku(['...'], {
  filter: /\.(m)?(j|t)?s$/,
  // filter: /\.(js|ts|mjs|mts)$/,
});
  • CLI
# Testing only a specific file

npx poku --include='...' --filter='some-file'
# Testing only a specific file

npx poku --include='...' --filter='some-file|other-file'
# Testing only paths that contains "unit"

npx poku --include='...' --filter='unit'
  • Environment Variable

By using FILTER from Environment Variable, it will overwrite the filter option.

# Testing only a specific file

FILTER='some-file' npx poku --include='...'
# Testing only a specific file

FILTER='some-file|other-file' npx poku --include='...'
# Testing only paths that contains "unit"

FILTER='unit' npx poku --include='...'

exclude: RexExp | RexExp[]

Exclude by path using Regex to match only the files that should be performed.

Since 1.2.0

  • in-code:
/**
 * Excluding  directories from tests
 */

poku(['...'], {
  exclude: /\/(helpers|tools)\//,
});
/**
 * Excluding  directories from tests
 */

poku(['...'], {
  exclude: [/\/helpers\//, /\/tools\//],
});
/**
 * Excluding specific files from tests
 */

poku(['...'], {
  exclude: /(index|common).test.ts/,
});
/**
 * Excluding specific files from tests
 */

poku(['...'], {
  exclude: [/index.test.ts/, /common.test.ts/],
});
/**
 * Excluding directories and files from tests
 */

poku(['...'], {
  exclude: /\/(helpers|tools)\/|(index|common).test.ts/,
});
/**
 * Excluding directories and files from tests
 */

poku(['...'], {
  exclude: [/\/helpers\//, /\/tools\//, /index.test.ts/, /common.test.ts/],
});
  • CLI
# Excluding directories and files from tests

npx poku --include='...' --exclude='some-file-or-dir'
# Excluding directories and files from tests

npx poku --include='...' --exclude='some-file-or-dir|other-file-or-dir'

listFiles(targetDir: string, configs?: ListFilesConfigs)

Since 1.2.0

Returns all files in a directory, independent of their depth.

listFiles('some-dir');
  • You can use the filter and exclude options, as well as they are for poku method.

Community

I'm continuously working to improve Poku. If you've got something interesting to share, feel free to submit a Pull Request. If you notice something wrong, I'd appreciate if you'd open an Issue.


Acknowledgements

Keywords

FAQs

Package last updated on 18 Feb 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc