Skip to main content
Version: v3.x.x

filter

Filter by path using Regex to match only the files that should be performed.
By default, Poku searches for .test. and .spec. files, but you can customize it using the filter option.

CLI​

# Default

npx poku --filter='.test.|.spec.' ./test
# Testing only a specific file

npx poku --filter='some-file' ./test
# Testing only specific files

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

npx poku --filter='unit' ./test
# Testing only paths that contains "unit" by using Poku as a NPM script

npm run tests -- --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 ./test
# Testing only specific files

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

FILTER='unit' npx poku ./test
# Testing only paths that contains "unit" by using Poku as a NPM script

FILTER='unit' npm run tests

API​

/**
* @default
*
* Testing all `*.test.*` files.
*/

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

await poku('./test', {
filter: /\.(m)?(j|t)s$/,
// filter: /\.(js|ts|mjs|mts)$/,
});