Skip to content

Commit

Permalink
feat: support for config files (json and jsonc) (#557)
Browse files Browse the repository at this point in the history
* ci(benchmark): fix package versions

* docs(typings): fix default filter value

* docs: minor adjustments

* feat: introduce initial set for config files

* chore: oganize types and comments

* docs: style adjustments

* docs: style adjustments

* docs: call adjustments

* docs: call adjustments

* ci: debug

* ci: debug

* ci: debug

* chore: fix parse return

* chore: support `jsonc`

* chore: improve polyfill performance

* chore: improve types

* ci: add tests

* chore: fix lint

* docs: add config documentation and example

* chore: add intellisense

* chore: fix order
  • Loading branch information
wellwelwel authored Jul 20, 2024
1 parent 71df0ac commit e954336
Show file tree
Hide file tree
Showing 47 changed files with 757 additions and 307 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci_benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: ➕ Actions - Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22.x'
node-version: '20.x'

- name: ➕ Cache dependencies
uses: actions/cache@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_docs-website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Actions - Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22.x'
node-version: '20.x'

- name: Cache Dependencies
uses: actions/cache@v4
Expand Down
10 changes: 9 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,13 @@
"htmlWhitespaceSensitivity": "css",
"endOfLine": "auto",
"embeddedLanguageFormatting": "auto",
"singleAttributePerLine": false
"singleAttributePerLine": false,
"overrides": [
{
"files": "*.jsonc",
"options": {
"trailingComma": "none"
}
}
]
}
59 changes: 17 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,62 +24,33 @@ Enjoying **Poku**? Give him a star to show your support 🌟

💡 **Poku** is a cross-platform test runner that brings the [**JavaScript** essence back to testing](https://poku.io/docs/philosophy#javascript-essence-for-tests-).

</span><img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> High **isolation** level per file<br />
</span><img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> **Performant** and **lightweight**<br />
<img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> Run **CommonJS** files directly with [**Deno**][deno-version-url]<br />
<img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> Auto detect **ESM**, **CJS**, and **TypeScript** files<br />
<img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> Run the same test suite for [**Node.js**][node-version-url], [**Bun**][bun-version-url], and [**Deno**][deno-version-url]<br />

<img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> _Easier and Less Verbose_<br />
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> Run **CJS** (**CommonJS**) files directly with [**Deno**][deno-version-url]<br />
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> Easily handle **servers**, **processes**, **ports**, and **containers**<br />

<img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> _Safety and Reliability_<br />
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> High **isolation** level per file<br />
<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> **Performant** and **lightweight**
<img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> Easily handle **servers**, **processes**, **ports**, and **containers**<br />

---

## Quickstart

### <img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> Install

<table>
<tr>
<td><blockquote><i>Node.js</i></blockquote></td>
<td><blockquote><i>TypeScript (Node.js)</i></blockquote></td>
<td><blockquote><i>Bun</i></blockquote></td>
<td><blockquote><i>Deno</i></blockquote></td>
</tr>
<tr>
<td width="400">

```bash
# Node.js
npm i -D poku
```

</td>
<td width="400">

```bash
# TypeScript (Node.js)
npm i -D poku tsx
```

</td>
<td width="400">

```bash
# Bun
bun add -d poku
```

</td>
<td width="400">

```bash
# Deno
deno add npm:poku
```

</td>
</tr>
</table>

---

### <img width="16" height="16" alt="check" src="https://raw.githubusercontent.com/wellwelwel/poku/main/.github/assets/readme/check.svg"> Test
Expand Down Expand Up @@ -146,8 +117,8 @@ deno run npm:poku

<table>
<tr>
<td width="250"><a href="https://poku.io/docs/category/-poku">poku</a></td>
<td width="800">🧪 Test runner.</td>
<td width="280"><a href="https://poku.io/docs/category/-poku">poku</a></td>
<td width="770">🧪 Test runner.</td>
</tr>
<tr>
<td><a href="https://poku.io/docs/documentation/assert">assert</a></td>
Expand Down Expand Up @@ -212,8 +183,8 @@ deno run npm:poku

<table>
<tr>
<td width="250"><a href="https://poku.io/docs/documentation/poku/options/watch">watch</a></td>
<td width="800">🍿 Watch for changes and re-run related test files.</td>
<td width="280"><a href="https://poku.io/docs/documentation/poku/options/watch">watch</a></td>
<td width="770">🍿 Watch for changes and re-run related test files.</td>
</tr>
<tr>
<td><a href="https://poku.io/docs/documentation/poku/options/parallel">parallel</a></td>
Expand All @@ -223,6 +194,10 @@ deno run npm:poku
<td><a href="https://poku.io/docs/documentation/poku/options/debug">debug</a></td>
<td>🕵🏻 Shows all logs.</td>
</tr>
<tr>
<td><a href="https://poku.io/docs/documentation/poku/config-files">config</a></td>
<td>⚙️ Customize your Poku options in a config file.</td>
</tr>
</table>

> _and much more_ 👇🏻
Expand Down Expand Up @@ -277,7 +252,7 @@ To see the detailed documentation, please visit the [**Documentation**](https://

## Security Policy

[![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&color=f8a5c2)](https://github.com/wellwelwel/poku/actions/workflows/ci_codeql.yml?query=branch%3Amain)
[![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&color=f368e0)](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 Down
10 changes: 4 additions & 6 deletions benchmark/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ 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 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)
- [x] **~1x** faster than [**Mocha**](https://github.com/mochajs/mocha) (v10.4.0) + [**Chai**](https://github.com/chaijs/chai) (v5.1.1)
- \>=**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)
- \>=**1x** faster than [**Mocha**](https://github.com/mochajs/mocha) (v10.4.0) + [**Chai**](https://github.com/chaijs/chai) (v5.1.1)

---

Expand All @@ -29,7 +29,5 @@ The testers to be compared are chosen based on the three most downloaded test ru
To run the benchmark tests, follow these steps in the `./poku` directory:

```sh
npm ci
npm run build
npm run benchmark
npm ci && npm run build && npm run benchmark
```
30 changes: 17 additions & 13 deletions benchmark/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions benchmark/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
"start": "node benchmark.js"
},
"devDependencies": {
"benchmark": "^2.1.4",
"chai": "^5.1.1",
"jest": "^29.7.0",
"mocha": "^10.4.0",
"poku": "^1.14.1",
"vitest": "^1.6.0"
"benchmark": "2.1.4",
"chai": "5.1.1",
"jest": "29.7.0",
"mocha": "10.4.0",
"poku": "latest",
"vitest": "1.6.0"
}
}
3 changes: 3 additions & 0 deletions fixtures/config-files/custom-file/custom.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"debug": true
}
Empty file.
3 changes: 3 additions & 0 deletions fixtures/config-files/json-no-ext/.pokurc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"debug": true
}
Empty file.
3 changes: 3 additions & 0 deletions fixtures/config-files/json-rc/.pokurc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"debug": true
}
Empty file.
3 changes: 3 additions & 0 deletions fixtures/config-files/json/poku.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"debug": true
}
Empty file.
18 changes: 18 additions & 0 deletions fixtures/config-files/jsonc-no-ext/.pokurc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* 123
*/
{
/**
* 123
*/





"debug": true /* yeah */
}




Empty file.
10 changes: 10 additions & 0 deletions fixtures/config-files/jsonc-rc/.pokurc.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* 123
*/
{
/**
* 123
*/

"debug": true /* yeah */
}
Empty file.
10 changes: 10 additions & 0 deletions fixtures/config-files/jsonc/poku.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* 123
*/
{
/**
* 123
*/

"debug": true /* yeah */
}
Empty file.
91 changes: 91 additions & 0 deletions fixtures/schemas/options.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Options",
"description": "The options that is contained inside the file `poku.json`",
"type": "object",
"properties": {
"$schema": {
"description": "A field for the [JSON schema](https://json-schema.org/) specification",
"type": ["string", "null"]
},
"include": {
"type": ["string", "array"],
"items": {
"type": "string"
},
"description": "Specify the path(s) to include in the configuration.\nhttps://poku.io/docs/documentation/poku/include-files",
"default": "."
},
"parallel": {
"type": "boolean",
"description": "Determines the mode of test execution.\nhttps://poku.io/docs/documentation/poku/options/parallel",
"default": false
},
"filter": {
"type": "string",
"description": "Filter by path to match only the files that should be performed.\nhttps://poku.io/docs/documentation/poku/options/filter",
"default": ".test.|.spec."
},
"exclude": {
"type": "string",
"description": "Exclude by path to match only the files that should be performed.\nhttps://poku.io/docs/documentation/poku/options/exclude"
},
"debug": {
"type": "boolean",
"description": "This option overwrites all `log` settings.\nhttps://poku.io/docs/documentation/poku/options/debug",
"default": false
},
"quiet": {
"type": "boolean",
"description": "This option overwrites the `debug` settings.\nhttps://poku.io/docs/documentation/poku/options/quiet",
"default": false
},
"concurrency": {
"type": "number",
"description": "Limits the number of tests running concurrently.\nhttps://poku.io/docs/documentation/poku/options/concurrency",
"default": 0
},
"failFast": {
"type": "boolean",
"description": "Stops the tests at the first failure.\nhttps://poku.io/docs/documentation/poku/options/fail-fast",
"default": false
},
"platform": {
"type": "string",
"description": "Determines the platform for test execution.\nhttps://poku.io/docs/documentation/poku/options/platform",
"default": "node",
"enum": ["node", "bun", "deno"]
},
"deno": {
"type": "object",
"description": "Exclusive options for Deno platform.\nhttps://poku.io/docs/documentation/poku/options/deno",
"properties": {
"allow": {
"type": "array",
"items": {
"type": "string"
},
"description": "Allow list for Deno permissions.\nhttps://poku.io/docs/documentation/poku/options/deno#allow"
},
"deny": {
"type": "array",
"items": {
"type": "string"
},
"description": "Deny list for Deno permissions.\nhttps://poku.io/docs/documentation/poku/options/deno#deny"
},
"cjs": {
"type": ["boolean", "array"],
"items": {
"type": "string"
},
"description": "CommonJS compatibility for Deno.\nhttps://poku.io/docs/documentation/poku/options/deno#cjs"
}
},
"additionalProperties": false,
"required": []
}
},
"required": [],
"additionalProperties": false
}
Loading

0 comments on commit e954336

Please sign in to comment.