Skip to content

Commit

Permalink
feat: set platform manually (#11)
Browse files Browse the repository at this point in the history
* chore: update dependencies

* docs: improve documentation

* feat: set platform manually

* ci: fix conflict between local and remote test

* ci: remove duplicated tests
  • Loading branch information
wellwelwel authored Feb 18, 2024
1 parent 0b78815 commit e681281
Show file tree
Hide file tree
Showing 10 changed files with 1,669 additions and 1,556 deletions.
149 changes: 112 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

<img align="right" width="128" height="128" alt="Logo" src=".github/assets/readme/poku.svg">

A flexible and easy-to-use **Test Runner** for [Node][node-version-url], [Bun][bun-version-url] and [Deno][deno-version-url] that allows you to run **parallel** and **sequential** tests, plus **high isolation level per test file**.
A flexible and easy-to-use **Test Runner** for [Node.js][node-version-url], [Bun][bun-version-url] and [Deno][deno-version-url] that allows you to run **parallel** and **sequential** tests, plus **high isolation level per test file**.

[![Node.js Version][node-version-image]][node-version-url]
[![Bun Version][bun-version-image]][bun-version-url]
Expand Down Expand Up @@ -176,117 +176,178 @@ npx poku --include='./targetDirA,./targetDirB'

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

#### `filter: RexExp`

By default, **Poku** searches for _`.test.`_ files, but you can customize it using the `filter` option.
#### `parallel: boolean`

> Filter by path using **Regex** to match only the files that should be performed.
Determines the mode of test execution across **sequential** or **parallel** modes.

- **in-code**

```ts
/**
* @default
*
* Testing all `*.test.*` files.
* Sequential mode
*/

poku(['...'], {
filter: /\.test\./,
parallel: false,
});
```

```ts
/**
* Testing all `ts`, `js`, `mts` and `mjs` files
* Parallel mode
*/

poku(['...'], {
filter: /\.(m)?(j|t)?s$/,
// filter: /\.(js|ts|mjs|mts)$/,
parallel: true,
});
```

- **CLI**

> _Since **1.2.0**_
```bash
# Testing only a specific file
# Parallel mode

npx poku --include='...' --filter='some-file'
npx poku --include='...' --parallel
```

```bash
# Testing only a specific file
---

npx poku --include='...' --filter='some-file|other-file'
```
#### `platform: "node" | "bun" | "deno"`

```bash
# Testing only paths that contains "unit"
> _Since **1.2.0**_
npx poku --include='...' --filter='unit'
By default, **Poku** tries to identify the platform automatically, but you can set it manually:

- **in-code**

```ts
/**
* Force Node.js (or tsx for TypeScript)
*
* @default 'node'
*/

poku('...', {
platform: 'node',
});
```

- **Environment Variable**
```ts
/**
* Force Bun
*/

> By using `FILTER` from **Environment Variable**, it will overwrite the `filter` option.
poku('...', {
platform: 'bun',
});
```

```bash
# Testing only a specific file
```ts
/**
* Force Deno
*/

FILTER='some-file' npx poku --include='...'
poku('...', {
platform: 'deno',
});
```

- **CLI**

```bash
# Testing only a specific file
# Normal

FILTER='some-file|other-file' npx poku --include='...'
npx poku --include='...' --platform=node
bun poku --include='...' --platform=bun
deno poku --include='...' --platform=deno
```

```bash
# Testing only paths that contains "unit"
# Custom

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

---

#### `parallel: boolean`
#### `filter: RexExp`

Determines the mode of test execution across **sequential** or **parallel** modes.
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**

```ts
/**
* @default
*
* Sequential mode
* Testing all `*.test.*` files.
*/

poku(['...'], {
parallel: false,
filter: /\.test\./,
});
```

```ts
/**
* Parallel mode
* Testing all `ts`, `js`, `mts` and `mjs` files
*/

poku(['...'], {
parallel: true,
filter: /\.(m)?(j|t)?s$/,
// filter: /\.(js|ts|mjs|mts)$/,
});
```

- **CLI**

> _Since **1.2.0**_
```bash
# Testing only a specific file

npx poku --include='...' --filter='some-file'
```

```bash
# Parallel mode
# Testing only a specific file

npx poku --include='...' --parallel
npx poku --include='...' --filter='some-file|other-file'
```

```bash
# 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.
```bash
# Testing only a specific file

FILTER='some-file' npx poku --include='...'
```

```bash
# Testing only a specific file

FILTER='some-file|other-file' npx poku --include='...'
```

```bash
# Testing only paths that contains "unit"

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

---
Expand Down Expand Up @@ -377,10 +438,24 @@ 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.

```ts
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**](https://github.com/wellwelwel/poku/compare). If you notice something wrong, I'd appreciate if you'd open an [**Issue**](https://github.com/wellwelwel/poku/issues/new).

---

## Acknowledgements

- [**Contributors**](https://github.com/wellwelwel/poku/graphs/contributors)
Loading

0 comments on commit e681281

Please sign in to comment.