diff --git a/.github/assets/readme/check.svg b/.github/assets/readme/check.svg
new file mode 100644
index 00000000..7675589e
--- /dev/null
+++ b/.github/assets/readme/check.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/.github/assets/readme/parallel.png b/.github/assets/readme/parallel.png
index fea54b82..1b8b55a9 100644
Binary files a/.github/assets/readme/parallel.png and b/.github/assets/readme/parallel.png differ
diff --git a/.github/assets/readme/sequential.png b/.github/assets/readme/sequential.png
index 7ea24099..19c0e1d5 100644
Binary files a/.github/assets/readme/sequential.png and b/.github/assets/readme/sequential.png differ
diff --git a/README.md b/README.md
index 477baf29..a3f740a9 100644
--- a/README.md
+++ b/README.md
@@ -15,49 +15,59 @@
[downloads-image]: https://img.shields.io/npm/dt/poku.svg?&color=FFC312&label=Downloads
[downloads-url]: https://npmjs.org/package/poku
-# Poku
-
-
+
+
-[**English**](https://poku.io/docs) | [**PortuguΓͺs (BR)**](https://poku.io/pt-BR/docs)
+# Poku
-**Poku** is your Test Runner Pet for [**Node.js**][node-version-url], [**Bun**][bun-version-url] and [**Deno**][deno-version-url].
+**Poku** can show you _how simple testing can be_ π±
[![Node.js Version][node-version-image]][node-version-url]
[![Bun Version][bun-version-image]][bun-version-url]
[![Deno Version][deno-version-image]][deno-version-url]
-[![TypeScript Version][typescript-version-image]][typescript-url]
+[![TypeScript Version][typescript-version-image]][typescript-url]
[![GitHub Workflow Status (with event)][ci-image]][ci-url]
[![GitHub Workflow Status (with event)][ql-image]][ql-url]
[![NPM Downloads][downloads-image]][downloads-url]
[![License][license-image]][license-url]
-
-
Enjoying **Poku**? Consider giving him a star βοΈ
+
+
---
-π· [**Documentation**](https://poku.io) β’ π§ͺ [**Examples**](https://poku.io/docs/category/examples) β’ π¬ [**Compare the Most Popular Test Runners**](https://poku.io/docs/comparing)
+
+
+π· [**Documentation**](https://poku.io) β’ π§ͺ [**Examples**](https://poku.io/docs/category/examples) β’ π¬ [**Compare the Most Popular Test Runners**](https://poku.io/docs/comparing)
+
+
---
-## Why Poku?
+## Reasons to Adopt a Poku β
+
+ No configurations
+ Auto detect **ESM** and **CJS**
+ Auto detect **Typescript** files
+ Don't export your **server** (_just run it_) π
-**Poku** can show you how simple testing can be π±
+ Less verbose
+ High **isolation** level per file
+ No eval needed π
+ **Parallel** and **Sequential** runs ππ½ππ»
-- No configurations
-- Supports **ESM** and **CJS**
-- High **isolation** level per file
-- **Poku** is [**100%** documented](https://poku.io/docs)
-- Zero external dependencies
-- **Parallel** and **Sequential** runs
-- Designed to be highly intuitive
-- Compatible with **Coverage** tools
-- [**Node.js**][node-version-url], [**Bun**][bun-version-url] and [**Deno**][deno-version-url] compatibility
-- You don't need to learn it all at once to get started π§π»βπ
+ **Poku** is [**100%** documented](https://poku.io/docs)
+ Designed to be human-friendly
+ **Poku** doesn't use a global state
+ Compatible with **Coverage** tools
+ [**Node.js**][node-version-url], [**Bun**][bun-version-url] and [**Deno**][deno-version-url] compatibility π©΅
-> _Poku adapts to your test, not the other way around._
+β¨ You are free to work with the packages you desire
+π§π»βπ You don't need to learn it all at once to get started
+π§π»βπ¬ **Poku** adapts to your test, not the other way around
+β Zero external dependencies (_that means **lightweight**_)
+π΄πΌ **Poku** doesn't restrict you from testing in legacy environments
---
@@ -251,6 +261,13 @@ Please check the [**SECURITY.md**](./SECURITY.md) and the section [**Is Poku Saf
---
+## Limitations
+
+- **Poku** is still a bit lonely, without an **active community** around him, but we can change it π€
+- Each file generates a sub-process during its execution. This can be reflected in projects with an extremely high volume of test files when run in parallel.
+
+---
+
## Acknowledgements
[![Contributors](https://img.shields.io/github/contributors/wellwelwel/poku)](https://github.com/wellwelwel/poku/graphs/contributors)
diff --git a/src/configs/each.ts b/src/configs/each.ts
index 485c168f..b073b1c8 100644
--- a/src/configs/each.ts
+++ b/src/configs/each.ts
@@ -18,13 +18,13 @@ export const each: {
before: {
status: true,
cb: undefined,
- assert: true,
+ assert: false,
test: true,
},
after: {
status: true,
cb: undefined,
- assert: true,
+ assert: false,
test: true,
},
};
diff --git a/src/modules/each.ts b/src/modules/each.ts
index 4c2ac3ff..55ac8d11 100644
--- a/src/modules/each.ts
+++ b/src/modules/each.ts
@@ -33,7 +33,7 @@ export const beforeEach = (
): Control => {
each.before.test = typeof options?.test === 'boolean' ? options.test : true;
each.before.assert =
- typeof options?.assert === 'boolean' ? options.assert : true;
+ typeof options?.assert === 'boolean' ? options.assert : false;
options?.immediate && callback();
@@ -83,7 +83,7 @@ export const afterEach = (
): Control => {
each.after.test = typeof options?.test === 'boolean' ? options.test : true;
each.after.assert =
- typeof options?.assert === 'boolean' ? options.assert : true;
+ typeof options?.assert === 'boolean' ? options.assert : false;
each.after.cb = () => {
if (each.after.status) callback();
diff --git a/website/docs/comparing.mdx b/website/docs/comparing.mdx
index 6e9f8ce1..19cf5093 100644
--- a/website/docs/comparing.mdx
+++ b/website/docs/comparing.mdx
@@ -3,7 +3,7 @@ import TabItem from '@theme/TabItem';
# Comparing Test Runners
-**Comparison using **Node.js**, **TypeScript** (_no compile_) and **ESM** to show a simple error test:**
+**Comparison using **TypeScript** (_no compile_) and **ESM** to show a simple error test:**
- Let's starting from installation π¬
diff --git a/website/docs/documentation/helpers/before-after-each/in-code.mdx b/website/docs/documentation/helpers/before-after-each/in-code.mdx
index cce908f0..21551618 100644
--- a/website/docs/documentation/helpers/before-after-each/in-code.mdx
+++ b/website/docs/documentation/helpers/before-after-each/in-code.mdx
@@ -7,12 +7,56 @@ import TabItem from '@theme/TabItem';
# In-Code
-## How can I combine `beforeEach`, `afterEach` and `assert`?
+## `beforeEach` and `afterEach`
Both `beforeEach`, `afterEach` are recommended for tests that consume a particular global state for each test.
For example, by populating or resetting a database before and/or after multiple assertions.
-### See how Poku solve it π§π»
+### Basic usage
+
+```ts
+import { test, beforeEach, afterEach } from 'poku';
+
+const prepareService = () => true;
+const resetService = () => true;
+
+beforeEach(() => prepareService());
+
+afterEach(() => resetService());
+
+test(() => {
+ // do anything you want
+});
+
+test(() => {
+ // do anything you want
+});
+```
+
+### By using promises
+
+```ts
+import { test, beforeEach, afterEach } from 'poku';
+
+const prepareService = () => new Promise((resolve) => resolve(true));
+
+const resetService = () => new Promise((resolve) => resolve(true));
+
+beforeEach(async () => await prepareService());
+afterEach(async () => await resetService());
+
+await test(async () => {
+ // do anything you want
+});
+
+await test(async () => {
+ // do anything you want
+});
+```
+
+## Combine `beforeEach`, `afterEach` and `assert`
+
+Since `test` is completely optional on **Poku**, you can use `beforeEach`, `afterEach` and `assert` together:
@@ -23,8 +67,8 @@ For example, by populating or resetting a database before and/or after multiple
const prepareService = () => true;
const resetService = () => true;
- beforeEach(() => prepareService());
- afterEach(() => resetService());
+ beforeEach(() => prepareService(), { assert: true });
+ afterEach(() => resetService(), { assert: true });
assert(true, 'Test A');
assert(true, 'Test B');
@@ -51,8 +95,8 @@ import { assert, beforeEach, afterEach } from 'poku';
let value = 0;
-beforeEach(() => ++value, { immediate: true });
-afterEach(() => ++value);
+beforeEach(() => ++value, { immediate: true, assert: true });
+afterEach(() => ++value, { assert: true });
assert.equal(value, 1); // β
assert.equal(value, 3); // β
diff --git a/website/docs/documentation/helpers/before-after-each/per-file.mdx b/website/docs/documentation/helpers/before-after-each/per-file.mdx
index 7e8a5767..3c4fe5ef 100644
--- a/website/docs/documentation/helpers/before-after-each/per-file.mdx
+++ b/website/docs/documentation/helpers/before-after-each/per-file.mdx
@@ -53,6 +53,10 @@ import Failure from '@site/static/img/each-fail.png';
+:::tip
+The "per-file" mode comes close to plugins, even though that wasn't the original intention.
+:::
+
:::danger
Although it also works with `parallel` runs, it's strongly discouraged to use these features for concurrent tests.
:::
diff --git a/website/docs/documentation/helpers/test.mdx b/website/docs/documentation/helpers/test.mdx
index 0cbdd755..7ded4950 100644
--- a/website/docs/documentation/helpers/test.mdx
+++ b/website/docs/documentation/helpers/test.mdx
@@ -8,59 +8,52 @@ sidebar_position: 3
`test` is a helper to assist you in such cases:
-- Use the beforeEach and afterEach for each `test` performed
+- Use the [`beforeEach` and `afterEach`](/docs/documentation/helpers/before-after-each/in-code) for each `test` performed
- Isolate or group your tests in the same file
+- Run tests in the same file in parallel
-```ts
-import { test, beforeEach, afterEach } from 'poku';
+## Basic Usage
-const prepareService = () => true;
-const resetService = () => true;
+```ts
+import { test, assert } from 'poku';
-beforeEach(() => prepareService(), {
- assert: false,
-});
+test(() => {
+ const myVar = 'a';
-afterEach(() => resetService(), {
- assert: false,
+ assert.strictEqual(myVar, 'a', 'My first test helper');
});
test(() => {
- // do anything you want
-});
+ const myVar = 'b';
-test(() => {
- // do anything you want
+ assert.strictEqual(myVar, 'b', 'My second test helper');
});
```
-:::info
-Ensure you disabled the assert on **beforeEach** and **afterEach**.
-:::
-
## By using promises
```ts
-import { test, beforeEach, afterEach } from 'poku';
+import { test, assert } from 'poku';
+
+await test(async () => {
+ // do anything you want
+});
-const prepareService = () =>
- new Promise((resolve) => resolve(true), {
- assert: false,
- });
+await test(async () => {
+ // do anything you want
+});
+```
-const resetService = () =>
- new Promise((resolve) => resolve(true), {
- assert: false,
- });
+## Running in Parallel
-beforeEach(async () => await prepareService());
-afterEach(async () => await resetService());
+```ts
+import { test, assert } from 'poku';
-await test(async () => {
+test(async () => {
// do anything you want
});
-await test(async () => {
+test(async () => {
// do anything you want
});
```
diff --git a/website/static/img/parallel.png b/website/static/img/parallel.png
index fea54b82..1b8b55a9 100644
Binary files a/website/static/img/parallel.png and b/website/static/img/parallel.png differ
diff --git a/website/static/img/sequential.png b/website/static/img/sequential.png
index 7ea24099..19c0e1d5 100644
Binary files a/website/static/img/sequential.png and b/website/static/img/sequential.png differ