Skip to content

Commit

Permalink
docs: improve documentation, example, and tutorials (#518)
Browse files Browse the repository at this point in the history
  • Loading branch information
wellwelwel authored Jul 6, 2024
1 parent 77d406c commit 1b21d25
Show file tree
Hide file tree
Showing 14 changed files with 657 additions and 452 deletions.
64 changes: 36 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<div align="center">
<img height="170" alt="Poku's Logo" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/poku.svg">
<img height="180" alt="Poku's Logo" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/poku.svg">

# Poku

Enjoying **Poku**? Give him a star to show your support 🌟

[![NPM Downloads][downloads-image]][downloads-url]
[![Coverage][coverage-image]][coverage-url]
[![License][license-image]][license-url]<br />
[![GitHub Workflow Status (with event)][ci-linux-image]][ci-linux-url]
[![GitHub Workflow Status (with event)][ci-osx-image]][ci-osx-url]
[![GitHub Workflow Status (with event)][ci-windows-image]][ci-windows-url]
[![NPM Downloads](https://img.shields.io/npm/dt/poku.svg?logo=npm&logoColor=white&color=1e90ff)](https://www.npmjs.com/package/poku)
[![Coverage](https://img.shields.io/codecov/c/github/wellwelwel/poku)](https://app.codecov.io/github/wellwelwel/poku)
[![License](https://img.shields.io/npm/l/poku?maxAge=2592000&color=9c88ff)](https://github.com/wellwelwel/poku/blob/main/LICENSE)<br />
[![GitHub Workflow Status (Linux)](https://img.shields.io/github/actions/workflow/status/wellwelwel/poku/ci_coverage-linux.yml?event=push&label=&branch=main&logo=ubuntu&logoColor=white)](https://github.com/wellwelwel/poku/actions/workflows/ci_coverage-linux.yml?query=branch%3Amain)
[![GitHub Workflow Status (OSX)](https://img.shields.io/github/actions/workflow/status/wellwelwel/poku/ci_coverage-osx.yml?event=push&label=&branch=main&logo=apple&logoColor=white)](https://github.com/wellwelwel/poku/actions/workflows/ci_coverage-osx.yml?query=branch%3Amain)
[![GitHub Workflow Status (Windows)](https://img.shields.io/github/actions/workflow/status/wellwelwel/poku/ci_coverage-windows.yml?event=push&label=&branch=main&logo=windows&logoColor=white)](https://github.com/wellwelwel/poku/actions/workflows/ci_coverage-windows.yml?query=branch%3Amain)

---

🐷 [Documentation](https://poku.io)<span>&nbsp;&nbsp;&nbsp;&nbsp;</span>🧪 [Examples](https://poku.io/docs/category/examples)<span>&nbsp;&nbsp;&nbsp;&nbsp;</span>🔬 [Compare the Most Popular Test Runners](https://poku.io/docs/comparing)
🐷 [Website](https://poku.io/)<span>&nbsp;&nbsp;&nbsp;&nbsp;</span>📒 [Documentation](https://poku.io/docs/category/documentation)<span>&nbsp;&nbsp;&nbsp;&nbsp;</span>🧪 [Examples](https://poku.io/docs/category/examples)<span>&nbsp;&nbsp;&nbsp;&nbsp;</span>🧑🏻‍🎓 [Quick Tutorials](https://poku.io/docs/tutorials)

</div>

Expand Down Expand Up @@ -154,7 +154,6 @@ deno run npm:poku
### Helpers

- [**test**](https://poku.io/docs/documentation/helpers/test), [**describe**](https://poku.io/docs/documentation/helpers/describe) and [**it**](https://poku.io/docs/documentation/helpers/it) _(organize, group, and isolate tests)_
- [**watch**](https://poku.io/docs/documentation/poku/options/watch) _(watch for changes and re-run related test files)_
- [**beforeEach**](https://poku.io/docs/category/-before-and-after-each) and [**afterEach**](https://poku.io/docs/category/-before-and-after-each) _(hooks for test setup and teardown)_
- [**docker**](https://poku.io/docs/documentation/helpers/containers) _(build, start, compose, stop, remove, and test containers)_
- [**startScript**](https://poku.io/docs/documentation/helpers/startScript) _(run **package.json** scripts in background)_
Expand All @@ -163,7 +162,14 @@ deno run npm:poku
- [**waitForPort**](https://poku.io/docs/documentation/helpers/processes/wait-for-port) _(wait for specified ports to become active)_
- [**waitForExpectedResult**](https://poku.io/docs/documentation/helpers/processes/wait-for-expected-result) _(retry until an expected result or times out)_
- [**getPIDs**](https://poku.io/docs/documentation/helpers/processes/get-pids) _(debug processes IDs using ports and port ranges)_
- _and much more_ 👇🏻

### Common Options

- [**watch**](https://poku.io/docs/documentation/poku/options/watch) _(watch for changes and re-run related test files)_
- [**parallel**](https://poku.io/docs/documentation/poku/options/parallel) _(run tests in parallel)_
- [**debug**](https://poku.io/docs/documentation/poku/options/debug) _(shows all logs)_

> _and much more_ 👇🏻
---

Expand All @@ -173,6 +179,19 @@ To see the detailed documentation, please visit the [**Documentation**](https://

---

### Tutorials

**Poku** offers _mini-lessons_ for different users needs in the [**Quick Tutorials**](https://poku.io/docs/tutorials) section.

---

### Common Issues

- [Avoiding conflicts in environments with multiple platforms installed](https://poku.io/docs/roadmaps/cross-platform#recommendations).
- [Properly running asynchronous tests on the same file](https://poku.io/docs/examples/promises).

---

## Contributing

See the [**Contributing Guide**](https://github.com/wellwelwel/poku/blob/main/CONTRIBUTING.md) and please follow our [**Code of Conduct**](https://github.com/wellwelwel/poku/blob/main/CODE_OF_CONDUCT.md) 🚀
Expand All @@ -181,7 +200,7 @@ See the [**Contributing Guide**](https://github.com/wellwelwel/poku/blob/main/CO

## Security Policy

[![GitHub Workflow Status (with event)][ql-image]][ql-url]
[![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/wellwelwel/poku/ci_codeql.yml?event=push&label=&branch=main&logo=github&logoColor=white)](https://github.com/wellwelwel/poku/actions/workflows/ci_codeql.yml?query=branch%3Amain)

Please check the [**SECURITY.md**](https://github.com/wellwelwel/poku/blob/main/SECURITY.md).

Expand All @@ -191,7 +210,7 @@ Please check the [**SECURITY.md**](https://github.com/wellwelwel/poku/blob/main/

### Performance

**Poku** is [continuously tested](https://github.com/wellwelwel/poku/blob/main/.github/workflows/ci_benchmark.yml) to ensure the following expectations:
**Poku** is [continuously tested](https://github.com/wellwelwel/poku/blob/main/.github/workflows/ci_benchmark.yml) to ensure the following expectations for basic usage:

- **~4x** faster than [**Jest**](https://github.com/jestjs/jest) (v29.7.0)
- **~3x** faster than [**Vitest**](https://github.com/vitest-dev/vitest) (v1.6.0)
Expand All @@ -215,8 +234,11 @@ Please check the [**SECURITY.md**](https://github.com/wellwelwel/poku/blob/main/

### Limitations

- Although it has no external dependencies, **Poku** is not _all-in-one_, so it doesn't have features such as _mocks_, _spies_, _coverage reports_, etc., where you can use your favorite packages or native solutions.
- **Poku** community is gradually building up.
- Although it has no external dependencies, **Poku** is not _all-in-one_, so it doesn't have integrated features such as _mocks_, _spies_, _coverage reports_, etc., where you can use your favorite packages or native solutions.
- See a [mock example](https://poku.io/docs/category/mock).
- **Poku** doesn't render components (such as **Angular**, **React**, etc.).
- See an [_end-to-end_ test example](https://poku.io/docs/examples/browser/react).
- Our community is gradually building up.

---

Expand All @@ -236,17 +258,3 @@ Please check the [**SECURITY.md**](https://github.com/wellwelwel/poku/blob/main/
[bun-version-url]: https://github.com/oven-sh/bun
[deno-version-url]: https://github.com/denoland/deno
[typescript-url]: https://github.com/microsoft/TypeScript
[ci-linux-url]: https://github.com/wellwelwel/poku/actions/workflows/ci_coverage-linux.yml?query=branch%3Amain
[ci-linux-image]: https://img.shields.io/github/actions/workflow/status/wellwelwel/poku/ci_coverage-linux.yml?event=push&label=&branch=main&logo=ubuntu&logoColor=white
[ci-osx-url]: https://github.com/wellwelwel/poku/actions/workflows/ci_coverage-osx.yml?query=branch%3Amain
[ci-osx-image]: https://img.shields.io/github/actions/workflow/status/wellwelwel/poku/ci_coverage-osx.yml?event=push&label=&branch=main&logo=apple&logoColor=white
[ci-windows-url]: https://github.com/wellwelwel/poku/actions/workflows/ci_coverage-windows.yml?query=branch%3Amain
[ci-windows-image]: https://img.shields.io/github/actions/workflow/status/wellwelwel/poku/ci_coverage-windows.yml?event=push&label=&branch=main&logo=windows&logoColor=white
[ql-url]: https://github.com/wellwelwel/poku/actions/workflows/ci_codeql.yml?query=branch%3Amain
[ql-image]: https://img.shields.io/github/actions/workflow/status/wellwelwel/poku/ci_codeql.yml?event=push&label=&branch=main&logo=github&logoColor=white
[coverage-image]: https://img.shields.io/codecov/c/github/wellwelwel/poku
[coverage-url]: https://app.codecov.io/github/wellwelwel/poku
[downloads-image]: https://img.shields.io/npm/dt/poku.svg?logo=npm&logoColor=white&color=1e90ff
[downloads-url]: https://www.npmjs.com/package/poku
[license-url]: https://github.com/wellwelwel/poku/blob/main/LICENSE
[license-image]: https://img.shields.io/npm/l/poku?maxAge=2592000&color=9c88ff
4 changes: 2 additions & 2 deletions benchmark/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ The testers to be compared are chosen based on the three most downloaded test ru

---

**Poku** is continuously tested ([**CI**](https://github.com/wellwelwel/poku/blob/main/.github/workflows/ci_benchmark.yml)) to ensure the following expectations:
**Poku** is continuously tested ([**CI**](https://github.com/wellwelwel/poku/blob/main/.github/workflows/ci_benchmark.yml)) to ensure the following expectations for basic usage:

- [x] **~4x** faster than [**Jest**](https://github.com/jestjs/jest) (v29.7.0)
- [x] **~3x** faster than [**Vitest**](https://github.com/vitest-dev/vitest) (v1.6.0)
Expand All @@ -26,7 +26,7 @@ The testers to be compared are chosen based on the three most downloaded test ru

## Running

To run the benchmark tests, follow these steps:
To run the benchmark tests, follow these steps in the `./poku` directory:

```sh
npm ci
Expand Down
58 changes: 35 additions & 23 deletions website/docs/documentation/poku/include-files.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,49 @@ sidebar_position: 1
## CLI

By setting the directories as the **last argument**:

> _Since **1.3.0**_
### Common usage

```bash
npx poku targetPath
# Same as ./
npx poku
```

- Run all tests sequentially.

```bash
npx poku targetPathA,targetPathB
# Same as ./
npx poku --parallel
```

- Run all tests in parallel.

:::tip
You can pass both directories and files.
:::

:::note
It's not possible to run tests in the `.git` and `node_modules` directories.
:::

<hr />

### By setting the directories as the last argument

> _Since **1.3.0**_
```bash
# Same as ./
npx poku
npx poku targetPath
```

```bash
# Same as ./
npx poku --parallel
npx poku targetPathA,targetPathB
```

By using `--include` option, you can use it in any order:
<hr />

### By using `--include` flag

Using the `--include` flag, you can use it in any order:

```bash
npx poku --include='targetPath'
Expand All @@ -46,26 +66,18 @@ npx poku --include='targetPathA,targetPathB'
npx poku --include='./'
```

<hr />

## API (_in-code_)

```ts
poku('targetPath');
await poku('targetPath');
```

```ts
poku(['targetPathA', 'targetPathB']);
await poku(['targetPathA', 'targetPathB']);
```

```ts
poku('./');
await poku('./');
```

<hr />

:::tip
The `targetPath` can be either a directory or a file.
:::

:::info
It's not possible to run tests in the `.git` and `node_modules` directories.
:::
4 changes: 0 additions & 4 deletions website/docs/examples/cjs-esm.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
---
sidebar_position: 4
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

Expand Down
135 changes: 135 additions & 0 deletions website/docs/examples/promises.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
---
title: Promises
tags: [examples, promise, beforeAll, afterAll, tutorial, roadmap]
sidebar_position: 0
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
import MidLevel from '@site/static/img/mid-level.svg';

# Promises

The use of native **JavaScript** syntax in tests is one of the major differences between Poku and other test runners, which is what makes it possible to use it on multiple platforms.

Here are some examples of sequential and concurrent tests in the same file plus how to perform an action after all the tests have been completed:

### Running async tests in the same file in parallel

```js
import { test, assert, sleep } from 'poku';

test(async () => {
const actual = 1;
const expected = 1;

await sleep(2000);

assert.strictEqual(actual, expected);
});

test(async () => {
const actual = 2;
const expected = 2;

await sleep(1000);

assert.strictEqual(actual, expected);
});
```

<hr />

### Running async tests in the same file sequentially (await top-level)

```js
import { test, assert, sleep } from 'poku';

await test(async () => {
const actual = 1;
const expected = 1;

await sleep(2000);

assert.strictEqual(actual, expected);
});

await test(async () => {
const actual = 2;
const expected = 2;

await sleep(1000);

assert.strictEqual(actual, expected);
});
```

<hr />

### Running async tests in the same file sequentially

```js
import { test, it, assert, sleep } from 'poku';

test(async () => {
await it(async () => {
const actual = 1;
const expected = 1;

await sleep(2000);

assert.strictEqual(actual, expected);
});

await it(async () => {
const actual = 2;
const expected = 2;

await sleep(1000);

assert.strictEqual(actual, expected);
});
});
```

<hr />

## Waiting for all the tests to run a post step

```js
import { test, assert, sleep } from 'poku';

console.log('Printing it before all tests 🏃🏻‍♀️');

await Promise.all([
test(async () => {
const actual = 1;
const expected = 1;

await sleep(2000);

assert.strictEqual(actual, expected);
}),

test(async () => {
const actual = 2;
const expected = 2;

await sleep(1000);

assert.strictEqual(actual, expected);
}),
]);

console.log('Printing it after all tests 😴');
```

:::tip
The same goes for `describe` and `it`.
:::

<hr />

:::note
If you find any typos, feel free to open a **Pull Request** correcting them.
:::
Loading

0 comments on commit 1b21d25

Please sign in to comment.