diff --git a/README.md b/README.md index 33faa392..65c613f9 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,8 @@ Logo +[**English**](https://poku.io/docs) | [**Português (BR)**](https://poku.io/pt-BR/docs) + **Poku** is your Test Runner Pet for [**Node.js**][node-version-url], [**Bun**][bun-version-url] and [**Deno**][deno-version-url]. [![Node.js Version][node-version-image]][node-version-url] @@ -47,6 +49,7 @@ By creating **Poku**, my aim is to show that testing can be simpler 🌱 - 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 diff --git a/website/docs/index.mdx b/website/docs/index.mdx index fb5f2573..196dee18 100644 --- a/website/docs/index.mdx +++ b/website/docs/index.mdx @@ -217,7 +217,7 @@ Please check the [**SECURITY.md**](https://github.com/wellwelwel/poku/blob/main/ ## Acknowledgements -[![Contributors](https://img.shields.io/github/contributors/wellwelwel/poku)](https://github.com/wellwelwel/poku/graphs/contributors) +[![Contributors](https://img.shields.io/github/contributors/wellwelwel/poku?label=Contributors)](https://github.com/wellwelwel/poku/graphs/contributors) + + +## [Poku](https://github.com/wellwelwel/poku) + +### Instalação + +```bash +npm i -D poku tsx +``` + +> ~10M + +
+ +### Criando o arquivo de teste + +> _test/index.test.ts_ + +```ts +import { assert } from 'poku'; + +assert.deepStrictEqual('1', 1, 'Número não deve ser uma string'); +``` + +
+ +### Executando o teste + +```bash +npx poku +``` + +
+ +É isso 🎉 + +:::tip + +O **Poku** não usa **`describe`** ou **`it`**, visto que a mensagem já está no **`assert`**. + +- O **`assert`** do **Poku** é apenas uma abstração do **`assert`** original do **Node.js**.
+- Isso significa: **Sem necessidade de novos aprendizados** 🎉 + +::: + +Adote um **Poku** pra você 🩵 + +
+ + +## [Jest](https://github.com/jestjs/jest) + +### Instalação + +```bash +npm i -D jest @types/jest ts-jest +``` + +> ~65M + +
+ +### Configurando o TypeScript + +> Adicione no seu _tsconfig.json_ + +```json +{ + "compilerOptions": { + "esModuleInterop": true + } +} +``` + +
+ +### Configurando o Jest + +> _jest.config.js_ + +```js +export default { + preset: 'ts-jest', + testEnvironment: 'node', + testMatch: ['**/test/**/*.test.ts'], +}; +``` + +
+ +### Criando o arquivo de teste + +> _test/index.test.ts_ + +```ts +describe('Comparação de Tipos', () => { + test('Número não deve ser uma string', () => { + expect('1').toStrictEqual(1); + }); +}); +``` + +
+ +### Executando o teste + +```bash +npx jest +``` + +
+ + +## [Mocha](https://github.com/mochajs/mocha) + [Chai](https://github.com/chaijs/chai) + +### Instalação + +```bash +npm i -D mocha @types/mocha chai @types/chai tsx +``` + +> ~18M + +
+ +### Configurando o Mocha + +> _.mocharc.json_ + +```json +{ + "require": "tsx", + "extension": ["ts"], + "spec": "./test/**/*.test.ts" +} +``` + +
+ +### Criando o arquivo de teste + +> _test/index.test.ts_ + +```ts +import { expect } from 'chai'; + +describe('Comparação de Tipos', () => { + it('Número não deve ser uma string', () => { + expect('1').to.deep.equal(1); + }); +}); +``` + +
+ +### Executando o teste + +```bash +npx mocha +``` + +
+ + +## [Vitest](https://github.com/vitest-dev/vitest) + +### Instalação + +```bash +npm i -D vitest ts-node +``` + +> ~66M + +
+ +### Configurando o Vitest + +> _vitest.config.ts_ + +```ts +import { defineConfig } from 'vitest/config'; + +export default defineConfig({ + test: { + include: ['test/**/*.test.ts'], + globals: true, + environment: 'node', + }, +}); +``` + +
+ +### Criando o arquivo de teste + +> _test/index.test.ts_ + +```ts +import { describe, it, expect } from 'vitest'; + +describe('Comparação de Tipos', () => { + it('Número não deve ser uma string', () => { + expect('1').toStrictEqual(1); + }); +}); +``` + +
+ +### Executando o teste + +```bash +npx vitest run +``` + +
+ + +## [AVA](https://github.com/avajs/ava) (CJS) + +:::info + +Não consegui testar o **AVA** como **ESM** sem antes compilar o **TypeScript**.
+Por favor, envie um _PR_ se você souber como chegar a essa abordagem. + +- Relacionado: [avajs/ava#3308](https://github.com/avajs/ava/discussions/3308). + +::: + +### Instalação + +```bash +npm i -D ava tsx +``` + +> ~26M + +
+ +### Configurando o AVA + +> Include in the _package.json_: + +```json +{ + "ava": { + "files": ["test/**/*.test.ts"], + "extensions": { + "ts": "commonjs" + }, + "nodeArguments": ["--import=tsx"] + } +} +``` + +
+ +### Criando o arquivo de teste + +> _test/index.test.ts_ + +```ts +import test from 'ava'; + +test('Número não deve ser uma string', (t) => { + t.deepEqual('1', 1); +}); +``` + +
+ +### Executando o teste + +```bash +npx ava +``` + +
+ diff --git a/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/documentation/assert/index.mdx b/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/documentation/assert/index.mdx new file mode 100644 index 00000000..c5432caa --- /dev/null +++ b/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/documentation/assert/index.mdx @@ -0,0 +1,96 @@ +--- +sidebar_position: 2 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +# `assert` + +**Poku** includes the `assert` method native from [**Node.js**][node-version-url], keeping everything as it is, but providing human readability.
+It supports both [**Bun**][bun-version-url] and [**Deno**][deno-version-url]. + +[node-version-url]: https://github.com/nodejs/node +[bun-version-url]: https://github.com/oven-sh/bun +[deno-version-url]: https://github.com/denoland/deno + +- [**Node.js**][node-version-url], [**Bun**][bun-version-url] and [**Deno**][deno-version-url] compatible. + +> The `assert` is used to write tests and verify if your code works as expected by comparing values and throwing errors, otherwise 🧑🏻‍🎓 +> +> _Since **1.3.0**_ + +## Migrating to **Poku**'s `assert` + +_But only if you want to, of course._ + + + + + ```diff + - import assert from 'node:assert'; + + import { assert } from 'poku'; + ``` + + + + + ```diff + - import assert from 'node:assert'; + + import { assert } from 'npm:poku'; + ``` + + + + +```ts +assert(true); +assert.deepStrictEqual(1, '1', 'My optional custom message'); +// ... +``` + +:::tip +**Poku**'s `assert` will use the message exactly as it is when using `describe` and `it`.
+Your **Poku** is waiting for you 🐷✨ +::: + +
+ +## Available methods + +```ts +import { assert, assertPromise } from 'poku'; +``` + +> You can combine promise **assert** with beforeEach and afterEach helpers. + +- `assert(value[, message])` +- `assert.deepEqual(actual, expected[, message])` +- `assert.deepStrictEqual(actual, expected[, message])` +- `assert.doesNotMatch(string, regexp[, message])` +- `assert.doesNotReject(asyncFn[, error][, message])` +- `assert.doesNotThrow(fn[, error][, message])` +- `assert.equal(actual, expected[, message])` +- `assert.fail([message])` +- `assert.ifError(value)` +- `assert.match(string, regexp[, message])` +- `assert.notDeepEqual(actual, expected[, message])` +- `assert.notDeepStrictEqual(actual, expected[, message])` +- `assert.notEqual(actual, expected[, message])` +- `assert.notStrictEqual(actual, expected[, message])` +- `assert.ok(value[, message])` +- `assert.rejects(asyncFn[, error][, message])` +- `assert.strictEqual(actual, expected[, message])` +- `assert.throws(fn[, error][, message])` + +You can follow the [**assert documentation**](https://nodejs.org/api/assert.html) from **Node.js**'s documentation. + +:::info + +To use `assert` with **TypeScript**, you may will need to instal **@types/node**: + +```bash +npm i -D @types/node +``` + +::: diff --git a/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/documentation/helpers/_category_.json b/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/documentation/helpers/_category_.json new file mode 100644 index 00000000..cc6797db --- /dev/null +++ b/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/documentation/helpers/_category_.json @@ -0,0 +1,7 @@ +{ + "label": "Helpers", + "collapsed": false, + "link": { + "type": "generated-index" + } +} diff --git a/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/documentation/helpers/before-after-each/_category_.json b/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/documentation/helpers/before-after-each/_category_.json new file mode 100644 index 00000000..93043d1d --- /dev/null +++ b/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/documentation/helpers/before-after-each/_category_.json @@ -0,0 +1,8 @@ +{ + "label": "beforeEach and afterEach", + "collapsed": true, + "link": { + "type": "generated-index" + }, + "position": 2 +} diff --git a/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/documentation/helpers/before-after-each/in-code.mdx b/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/documentation/helpers/before-after-each/in-code.mdx new file mode 100644 index 00000000..cce908f0 --- /dev/null +++ b/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/documentation/helpers/before-after-each/in-code.mdx @@ -0,0 +1,255 @@ +--- +sidebar_position: 2 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +# In-Code + +## How can I combine `beforeEach`, `afterEach` and `assert`? + +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 🧙🏻 + + + + + ```ts + import { assert, beforeEach, afterEach } from 'poku'; + + const prepareService = () => true; + const resetService = () => true; + + beforeEach(() => prepareService()); + afterEach(() => resetService()); + + assert(true, 'Test A'); + assert(true, 'Test B'); + assert(true, 'Test C'); + assert(true, 'Test D'); + ``` + +:::tip + +- ✅ Handling **global** and **external** services (_preparing a database, for example_) +- ✅ It's made for **exclusive use** in combination with **Poku**'s **`assert`** methods +- ✅ You can combine `beforeEach`, `afterEach` and all `assert` methods, except for `assert.fail(message?: string)`. + +::: + +:::info + +- Although `beforeEach` and `afterEach` accepts local variables changes, it's strongly encouraged ([_you can use a mock instead_](/docs/category/mock)). + +See why (_note the `immediate` option_): + +```ts +import { assert, beforeEach, afterEach } from 'poku'; + +let value = 0; + +beforeEach(() => ++value, { immediate: true }); +afterEach(() => ++value); + +assert.equal(value, 1); // ✅ +assert.equal(value, 3); // ✅ + +// ✋ In the `eachBefore` context, `value` is now `4`, while locally it's `5` +console.log(value); +``` + +::: + + + + + ```ts + import { assert } from 'poku'; + + const prepareService = () => true; + const resetService = () => true; + + prepareService(); + assert(true, 'Test A'); + resetService(); + + prepareService(); + assert(true, 'Test B'); + resetService(); + + prepareService(); + assert(true, 'Test C'); + resetService(); + + prepareService(); + assert(true, 'Test D'); + resetService(); + ``` + + + + +**Poku** provides three optional methods from both `beforeEach` and `afterEach`: + + - `.pause()` + - `.continue()` + - `.reset()` + + ```ts + import { assert, beforeEach, afterEach } from 'poku'; + + const prepareService = () => true; + const resetService = () => true; + + const before = beforeEach(() => prepareService()); + const after = afterEach(() => resetService()); + + assert.ok(true, 'Test A'); + assert.ok(true, 'Test B'); + + before.pause(); + + assert.ok(true, 'Test C'); + assert.ok(true, 'Test D'); + + before.continue(); + + assert.ok(true, 'Test E'); + + // From now, it will not run beforeEach until you declare it again. + before.reset(); + + assert.ok(true, 'Test F'); + ``` + +:::tip +You can overwriting both `beforeEach` and `afterEach` by declaring them again anytime. +::: + + + + +### By using Promises + + + + + ```ts + import { assertPromise as assert, 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 assert(true, 'Test A'); + await assert(true, 'Test B'); + await assert(true, 'Test C'); + await assert(true, 'Test D'); + ``` + +:::tip + +- ✅ Handling **global** and **external** services (_preparing a database, for example_) +- ✅ It's made for **exclusive use** in combination with **Poku**'s **`assert`** methods +- ✅ You can combine `beforeEach`, `afterEach` and all `assert` methods, except for `assert.fail(message?: string)`. + +::: + +:::info + +- Although `beforeEach` and `afterEach` accepts local variables changes, it's strongly encouraged ([_you can use a mock instead_](/docs/category/mock)). + +See why (_note the `immediate` option_): + +```ts +import { assertPromise as assert, beforeEach, afterEach } from 'poku'; + +let value = 0; + +beforeEach(async () => new Promise((resolve) => resolve(++value)), { + immediate: true, +}); +afterEach(async () => new Promise((resolve) => resolve(++value))); + +await assert.equal(value, 1); // ✅ +await assert.equal(value, 3); // ✅ + +// ✋ In the `eachBefore` context, `value` is now `4`, while locally it's `5` +console.log(value); +``` + +::: + + + + + ```ts + import { assert } from 'poku'; + + const prepareService = () => new Promise((resolve) => resolve(true)); + const resetService = () => new Promise((resolve) => resolve(true)); + + await prepareService(); + assert(true, 'Test A'); + await resetService(); + + await prepareService(); + assert(true, 'Test B'); + await resetService(); + + await prepareService(); + assert(true, 'Test C'); + await resetService(); + + await prepareService(); + assert(true, 'Test D'); + await resetService(); + ``` + + + + + **Poku** provides three optional methods from both `beforeEach` and `afterEach`: + + - `.pause()` + - `.continue()` + - `.reset()` + + ```ts + import { assertPromise as assert, beforeEach, afterEach } from 'poku'; + + const prepareService = () => new Promise((resolve) => resolve(true)); + const resetService = () => new Promise((resolve) => resolve(true)); + + const before = await beforeEach(async () => await prepareService()); + const after = await afterEach(async () => await resetService()); + + await assert.ok(true, 'Test A'); + await assert.ok(true, 'Test B'); + + before.pause(); + + await assert.ok(true, 'Test C'); + await assert.ok(true, 'Test D'); + + before.continue(); + + await assert.ok(true, 'Test E'); + + // From now, it will not run beforeEach until you declare it again. + before.reset(); + + await assert.ok(true, 'Test F'); + ``` + +:::tip +You can overwriting both `beforeEach` and `afterEach` by declaring them again anytime. +::: + + + diff --git a/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/documentation/helpers/before-after-each/per-file.mdx b/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/documentation/helpers/before-after-each/per-file.mdx new file mode 100644 index 00000000..6a1083f0 --- /dev/null +++ b/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/documentation/helpers/before-after-each/per-file.mdx @@ -0,0 +1,58 @@ +--- +sidebar_position: 1 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import { FAQ } from '@site/src/components/FAQ'; +import Success from '@site/static/img/each-success.png'; +import Failure from '@site/static/img/each-fail.png'; + +# Per File + +## Running a callback before and after each test file + +- [x] `poku` **API (_in-code_)** +- [ ] `poku` **CLI** + +**Poku** brings a simple way to perform a callback before and/or after every test file. + + + + + ```ts + import { poku } from 'poku'; + + const prepareService = () => new Promise((resolve) => resolve(undefined)); + const resetService = () => new Promise((_, reject) => reject('Let\'s crash it')); + + await poku('test/unit', { + beforeEach: prepareService, + afterEach: resetService, + }); + ``` + + ```bash + npx poku test/run.test.js + ``` + + + + + + + + + + + + + + + + +
+ +:::info +Although it also works with `parallel` runs, it's strongly discouraged to use these features for sequential tests. +::: diff --git a/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/documentation/helpers/describe.mdx b/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/documentation/helpers/describe.mdx new file mode 100644 index 00000000..8fc16509 --- /dev/null +++ b/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/documentation/helpers/describe.mdx @@ -0,0 +1,124 @@ +--- +sidebar_position: 1 +--- + +import { FAQ } from '@site/src/components/FAQ'; +import Example from '@site/static/img/describe-example.png'; + +# describe + +On **Poku**, `describe` is just a pretty `console.log` to title your test suites in the terminal. + +```ts +import { describe, assert } from 'poku'; + +describe('Group A'); +assert(true, '1'); +assert(true, '2'); + +describe('Group B'); +assert(true, '1'); +assert(true, '2'); +``` + +## Personalization + +> `describe(title: string, options?: DescribeOptions)` + +### pad + +Skips a line before to console it. + +```ts +import { describe, assert } from 'poku'; + +describe('Group A', { pad: true }); +assert.ok(true, '1'); +assert.ok(true, '2'); +``` + +### background + +Change the background color for your personal title. + +> Set `false` to disable it. + +```ts +import { describe, assert } from 'poku'; + +describe('Group A', { background: 'blue' }); +assert.ok(true, '1'); +assert.ok(true, '2'); +``` + + + +- `white` +- `black` +- `grey` +- `red` +- `green` +- `yellow` +- `blue` +- `magenta` +- `cyan` +- `brightRed` +- `brightGreen` +- `brightYellow` +- `brightBlue` +- `brightMagenta` +- `brightCyan` + + + +### icon (prefix) + +**Poku** also allows the prefix customization. + +> The default icon is `☰`. + +```ts +import { describe, assert } from 'poku'; + +describe('Group A', { icon: '🚀' }); +assert.ok(true, '1'); +assert.ok(true, '2'); +``` + +
+ +## Overview + + + + ```ts + import { assert, describe } from 'poku'; + + describe('Needs to Succeed', { + pad: true, + background: false, + icon: '🚀', + }); + + assert.ok(true, 'Test 1'); + assert.ok(true, 'Test 2'); + + describe('Needs to Fail', { + pad: true, + background: 'yellow', + icon: '🚫', + }); + + assert.throws(() => { throw new Error() }, 'Test 1'); + assert.throws(() => { throw new Error() }, 'Test 2'); + ``` + + + + + + + +
+ +
diff --git a/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/documentation/helpers/list-files.mdx b/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/documentation/helpers/list-files.mdx new file mode 100644 index 00000000..88285cfe --- /dev/null +++ b/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/documentation/helpers/list-files.mdx @@ -0,0 +1,23 @@ +# `listFiles` + +> `listFiles(targetDir: string, configs?: ListFilesConfigs)` + +Returns all files in a directory, independent of their depth. + +> _Since **1.2.0**_ + +```ts +listFiles('some-dir'); +``` + +- You can use the `filter` and `exclude` options, as well as they are for **`poku`** method. + +:::info + +To use `listFiles` with **TypeScript**, you will need to instal **@types/node**: + +```bash +npm i -D @types/node +``` + +::: diff --git a/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/documentation/helpers/log.mdx b/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/documentation/helpers/log.mdx new file mode 100644 index 00000000..009c1639 --- /dev/null +++ b/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/documentation/helpers/log.mdx @@ -0,0 +1,19 @@ +--- +sidebar_position: 3 +--- + +# log + +Since by default **Poku** only shows outputs generated from itself, this helper allows you to use an alternative to `console.log` with **Poku** runner. + +```ts +import { log } from 'poku'; + +log('Poku will show it'); + +console.log("Poku won't show that"); +``` + +:::tip +Need to debug? Just use the [`debug`](/docs/documentation/poku/configs/debug) option from `poku`. +::: diff --git a/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/documentation/poku/_category_.json b/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/documentation/poku/_category_.json new file mode 100644 index 00000000..718b0706 --- /dev/null +++ b/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/documentation/poku/_category_.json @@ -0,0 +1,8 @@ +{ + "label": "poku", + "collapsed": false, + "link": { + "type": "generated-index" + }, + "position": 1 +} diff --git a/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/documentation/poku/configs/_category_.json b/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/documentation/poku/configs/_category_.json new file mode 100644 index 00000000..5b7d7c3e --- /dev/null +++ b/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/documentation/poku/configs/_category_.json @@ -0,0 +1,8 @@ +{ + "label": "Configs", + "collapsed": true, + "link": { + "type": "generated-index" + }, + "position": 2 +} diff --git a/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/documentation/poku/configs/debug.mdx b/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/documentation/poku/configs/debug.mdx new file mode 100644 index 00000000..cc5efb07 --- /dev/null +++ b/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/documentation/poku/configs/debug.mdx @@ -0,0 +1,27 @@ +--- +sidebar_position: 6 +--- + +# `debug` + +> `poku(targetPaths: string | string[], configs?: Configs)` +> +> `debug: boolean` + +By default **Poku** doesn't shows logs that doesn't comes from **Poku**'s **`assert`**, but you can enable them: + +> _Since **1.5.0**_ + +## API (_in-code_) + +```ts +poku(['...'], { + debug: true, +}); +``` + +## CLI + +```bash +npx poku --debug ./test +``` diff --git a/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/documentation/poku/configs/exclude.mdx b/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/documentation/poku/configs/exclude.mdx new file mode 100644 index 00000000..4e1656f7 --- /dev/null +++ b/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/documentation/poku/configs/exclude.mdx @@ -0,0 +1,89 @@ +--- +sidebar_position: 4 +--- + +# `exclude` + +> `poku(targetPaths: string | string[], configs?: Configs)` +> +> `exclude: RegExp | RegExp[]` + +Exclude by path using Regex to match only the files that should be performed. + +> _Since **1.2.0**_ + +## API (_in-code_) + +```ts +/** + * Excluding directories from tests + */ + +poku(['...'], { + exclude: /\/(helpers|tools)\//, +}); +``` + +```ts +/** + * Excluding directories from tests + */ + +poku(['...'], { + exclude: [/\/helpers\//, /\/tools\//], +}); +``` + +```ts +/** + * Excluding specific files from tests + */ + +poku(['...'], { + exclude: /(index|common).test.ts/, +}); +``` + +```ts +/** + * Excluding specific files from tests + */ + +poku(['...'], { + exclude: [/index.test.ts/, /common.test.ts/], +}); +``` + +```ts +/** + * Excluding directories and files from tests + */ + +poku(['...'], { + exclude: /\/(helpers|tools)\/|(index|common).test.ts/, +}); +``` + +```ts +/** + * Excluding directories and files from tests + */ + +poku(['...'], { + exclude: [/\/helpers\//, /\/tools\//, /index.test.ts/, /common.test.ts/], +}); +``` + +## CLI + +```bash +# Excluding directories and files from tests + +npx poku --exclude='some-file-or-dir' ./test +``` + +```bash +# Excluding directories and files from tests + +npx poku --exclude='some-file-or-dir|other-file-or-dir' ./test +``` diff --git a/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/documentation/poku/configs/filter.mdx b/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/documentation/poku/configs/filter.mdx new file mode 100644 index 00000000..7d8c97c1 --- /dev/null +++ b/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/documentation/poku/configs/filter.mdx @@ -0,0 +1,85 @@ +--- +sidebar_position: 2 +--- + +# `filter` + +> `poku(targetPaths: string | string[], configs?: Configs)` +> +> `filter: RegExp` + +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. + +## API (_in-code_) + +```ts +/** + * @default + * + * Testing all `*.test.*` files. + */ + +poku(['...'], { + filter: /\.test\./, +}); +``` + +```ts +/** + * Testing all `ts`, `js`, `mts` and `mjs` files + */ + +poku(['...'], { + filter: /\.(m)?(j|t)s$/, + // filter: /\.(js|ts|mjs|mts)$/, +}); +``` + +## CLI + +```bash +# Testing only a specific file + +npx poku --filter='some-file' ./test +``` + +```bash +# Testing only a specific file + +npx poku --filter='some-file|other-file' ./test +``` + +```bash +# Testing only paths that contains "unit" + +npx poku --filter='unit' ./test +``` + +## 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 ./test +``` + +```bash +# Testing only a specific file + +FILTER='some-file|other-file' npx poku ./test +``` + +```bash +# Testing only paths that contains "unit" + +FILTER='unit' npx poku ./test +``` + +```bash +# Testing only paths that contains "unit" by using Poku as a NPM script + +FILTER='unit' npm run tests +``` diff --git a/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/documentation/poku/configs/no-exit.mdx b/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/documentation/poku/configs/no-exit.mdx new file mode 100644 index 00000000..bcf57767 --- /dev/null +++ b/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/documentation/poku/configs/no-exit.mdx @@ -0,0 +1,39 @@ +--- +sidebar_position: 7 +--- + +# `noExit` + +> `poku(targetPaths: string | string[], configs?: Configs)` +> +> `noExit: boolean` + +By setting `noExit` to `true`, **Poku** won't exit the process and will return the exit code (`0` or `1`).
+You can combine this option with **Poku**'s `exit` method or just use the result, for example: `process.exit(code)`. + +## API (_in-code_) + +```ts +import { poku, exit } from 'poku'; + +const unit = await poku('test/unit', { + noExit: true, + parallel: true, + quiet: true, +}); + +// do something + +const integration = await poku('test/integration', { + noExit: true, + quiet: true, +}); + +// do something more + +const code = unit === 0 && integration === 0 ? 0 : 1; + +// do something more again + +exit(code); +``` diff --git a/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/documentation/poku/configs/parallel.mdx b/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/documentation/poku/configs/parallel.mdx new file mode 100644 index 00000000..ad6f3c62 --- /dev/null +++ b/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/documentation/poku/configs/parallel.mdx @@ -0,0 +1,41 @@ +--- +sidebar_position: 1 +--- + +# `parallel` + +> `poku(targetPaths: string | string[], configs?: Configs)` +> +> `parallel: boolean` + +## API (_in-code_) + +```ts +/** + * @default + * + * Sequential mode + */ + +poku(['...'], { + parallel: false, +}); +``` + +```ts +/** + * Parallel mode + */ + +poku(['...'], { + parallel: true, +}); +``` + +## CLI + +```bash +# Parallel mode + +npx poku --parallel ./test +``` diff --git a/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/documentation/poku/configs/platform.mdx b/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/documentation/poku/configs/platform.mdx new file mode 100644 index 00000000..6937bdbe --- /dev/null +++ b/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/documentation/poku/configs/platform.mdx @@ -0,0 +1,72 @@ +--- +sidebar_position: 3 +--- + +# `platform` + +> `poku(targetPaths: string | string[], configs?: Configs)` +> +> `platform: "node" | "bun" | "deno"` + +> _Since **1.2.0**_ + +By default, **Poku** tries to identify the platform automatically, but you can set it manually: + +## API (_in-code_) + +```ts +/** + * Force Node.js (or tsx for TypeScript) + * + * @default 'node' + */ + +poku('...', { + platform: 'node', +}); +``` + +```ts +/** + * Force Bun + */ + +poku('...', { + platform: 'bun', +}); +``` + +```ts +/** + * Force Deno + */ + +poku('...', { + platform: 'deno', +}); +``` + +## CLI + +```bash +# Normal + +npx poku --platform=node ./test +bun poku --platform=bun ./test +deno run npm:poku --platform=deno ./test +``` + +```bash +# Custom +# When you're developing using a platform, but maintain compatibility with others + +npx poku --platform=bun ./test +bun poku --platform=deno ./test +deno run npm:poku --platform=node ./test + +# ... +``` + +:::tip +Useful when there is more than one common platform installed. +::: diff --git a/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/documentation/poku/configs/quiet.mdx b/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/documentation/poku/configs/quiet.mdx new file mode 100644 index 00000000..8984a43c --- /dev/null +++ b/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/documentation/poku/configs/quiet.mdx @@ -0,0 +1,28 @@ +--- +sidebar_position: 5 +--- + +# `quiet` + +> `poku(targetPaths: string | string[], configs?: Configs)` +> +> `quiet: boolean` + +Perform tests with no logs.
+This option overwrites all `log` settings by exiting with code and no logs (see bellow). + +## API (_in-code_) + +```ts +poku(['...'], { + quiet: true, +}); +``` + +## CLI + +> _Since **1.3.1**_ + +```bash +npx poku --quiet ./test +``` diff --git a/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/documentation/poku/include-files.mdx b/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/documentation/poku/include-files.mdx new file mode 100644 index 00000000..99643476 --- /dev/null +++ b/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/documentation/poku/include-files.mdx @@ -0,0 +1,56 @@ +--- +sidebar_position: 1 +--- + +# Include Directories and Files + +> `poku(targetPaths: string | string[])` +> +> By default, **Poku** searches for _`.test.`_ and `.spec.` files, but you can customize it using the [`filter`](/docs/documentation/poku/configs/filter) option. + +## API (_in-code_) + +```ts +poku('targetePath'); +``` + +```ts +poku(['targetePathA', 'targetePathB']); +``` + +```ts +poku('./'); +``` + +## CLI + +By setting the directories as the **last argument**: + +> _Since **1.3.0**_ + +```bash +npx poku targetePath +``` + +```bash +npx poku targetePathA,targetePathB +``` + +```bash +# Same as ./ +npx poku +``` + +By using `--include` option, you can use it in any order: + +```bash +npx poku --include='targetePath' +``` + +```bash +npx poku --include='targetePathA,targetePathB' +``` + +```bash +npx poku --include='./' +``` diff --git a/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/examples/DOM.mdx b/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/examples/DOM.mdx new file mode 100644 index 00000000..886b0a5c --- /dev/null +++ b/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/examples/DOM.mdx @@ -0,0 +1,25 @@ +--- +sidebar_position: 3 +--- + +# Virtual DOM + +Let's simule a **Virtual DOM** (Browser) by using [**jsdom**](https://github.com/jsdom/jsdom), then testing its results with **Poku**: + +```ts +import { assert } from 'poku'; +import { JSDOM } from 'jsdom'; + +const dom = new JSDOM('
Poku
'); +const document = dom.window.document; + +const name = document.querySelector('#name'); + +assert.strictEqual(name?.textContent, 'Poku', 'My div contains a Poku 🐷'); +``` + +Then: + +```bash +npx poku +``` diff --git a/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/examples/cases/_category_.json b/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/examples/cases/_category_.json new file mode 100644 index 00000000..f7ce81ca --- /dev/null +++ b/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/examples/cases/_category_.json @@ -0,0 +1,7 @@ +{ + "label": "Use Cases", + "collapsed": true, + "link": { + "type": "generated-index" + } +} diff --git a/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/examples/cases/compexy-no-exit.mdx b/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/examples/cases/compexy-no-exit.mdx new file mode 100644 index 00000000..3735cc61 --- /dev/null +++ b/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/examples/cases/compexy-no-exit.mdx @@ -0,0 +1,76 @@ +# A Complex Case + +**Imagine these steps to perform a test:** + +1. Perform **Unit Tests** suite in parallel +2. Clear and Populate the Database +3. Check for **Expected Successes Integration** suite sequentially +4. Clear and Populate the Database — again +5. Check for **Expected Failures Integration** suite sequentially + +**Requirements:** + +Each step requires success to be processed. + +**Directory Structure:** + +```bash +├── . +├── test +│ ├── unit +│ ├── integration +│ │ ├── successes +│ │ │ └── **/.spec.js +│ │ └── failures +│ │ └── **/.spec.js +│ ├─ run.test.js # The runner +│ ├─ tools.test.js +``` + +> Do we really need to complicate things even more by creating advanced tests runs to run our already complex tests? 😅 + +### Poku's Solution ✨ + +```ts +import { poku, assert } from 'poku'; +import { recreateDatabase } from './tools.test.js'; + +const unitCode = await poku('test/unit', { + parallel: true, + noExit: true, +}); + +assert.strictEqual(0, unitCode, 'Running Unit Tests'); + +await assert.doesNotReject( + recreateDatabase(), + 'Preparing DB for Successes Integration Tests' +); + +const successesCode = await poku('test/integration/successes', { + noExit: true, +}); + +assert.strictEqual(0, successesCode, 'Running Successes Integration Tests'); + +await assert.doesNotReject( + recreateDatabase(), + 'Preparing DB for Successes Integration Tests' +); + +const failuresCode = await poku('test/integration/failures', { + noExit: true, +}); + +assert.strictEqual(0, failuresCode, 'Running Failures Integration Tests'); +``` + +> Why comment the code if we can do it better? 🧙🏻 + +**Finally** + +```bash +npx poku test/run.test.js +``` + +> Or `npx poku test/run.test.ts` for **TypeScript**. diff --git a/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/examples/cjs-esm.mdx b/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/examples/cjs-esm.mdx new file mode 100644 index 00000000..e9339793 --- /dev/null +++ b/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/examples/cjs-esm.mdx @@ -0,0 +1,32 @@ +--- +sidebar_position: 4 +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +# CJS and ESM + +Just set your **package.json** as usual and that's it.
+**Poku** doesn't require any configuration 🐷 + + + + +```json +{ + "type": "commonjs" +} +``` + + + + +```json +{ + "type": "module" +} +``` + + + diff --git a/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/examples/mock/_category_.json b/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/examples/mock/_category_.json new file mode 100644 index 00000000..71abb29d --- /dev/null +++ b/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/examples/mock/_category_.json @@ -0,0 +1,8 @@ +{ + "label": "Mock", + "collapsed": true, + "link": { + "type": "generated-index" + }, + "position": 2 +} diff --git a/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/examples/mock/cjs.mdx b/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/examples/mock/cjs.mdx new file mode 100644 index 00000000..6f498499 --- /dev/null +++ b/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/examples/mock/cjs.mdx @@ -0,0 +1,64 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +# Mock using CJS + +You can use your favorite **Mock** framework or tool and **Poku** together 🐷➕ + +For this example, let's use the [**quibble**](https://github.com/testdouble/quibble), then testing its results with **Poku**: + + + + + ```js + const { assert } = require('poku'); + const quibble = require('quibble'); + + (async () => { + await quibble('../lib/funds.js', { + // Original: 100 + getFunds: () => 200, + }); + + const { withdraw } = require('../lib/withdraw.js'); + + assert.strictEqual(withdraw(200), true, 'Mocking my funds to 200'); + + assert.strictEqual(withdraw(300), false, "I can't get more than I have"); + + await quibble.reset(); + })(); + ``` + + + + + ```js + const getFunds = () => 100; + + module.exports = { getFunds }; + ``` + + + + + ```js + const { getFunds } = require('./funds.js'); + + const withdraw = (value) => { + const wallet = getFunds(); + + return value <= wallet; + }; + + module.exports = { withdraw }; + ``` + + + + +Then: + +```bash +npx poku +``` diff --git a/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/examples/mock/esm.mdx b/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/examples/mock/esm.mdx new file mode 100644 index 00000000..fe0120f8 --- /dev/null +++ b/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/examples/mock/esm.mdx @@ -0,0 +1,58 @@ +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; + +# Mock using ESM + +You can use your favorite **Mock** framework or tool and **Poku** together 🐷➕ + +For this example, let's use the [**quibble**](https://github.com/testdouble/quibble), then testing its results with **Poku**: + + + + + ```js + import { assert } from 'poku'; + import quibble from 'quibble'; + + await quibble.esm('../lib/funds.js', { + // Original: 100 + getFunds: () => 200, + }); + + const { withdraw } = await import('../lib/withdraw.test.js'); + + assert.strictEqual(withdraw(200), true, 'Mocking my funds to 200'); + + assert.strictEqual(withdraw(300), false, "I can't get more than I have"); + + await quibble.reset(); + ``` + + + + + ```js + export const getFunds = () => 100; + ``` + + + + + ```js + import { getFunds } from './funds.js'; + + export const withdraw = (value) => { + const wallet = getFunds(); + + return value <= wallet; + }; + ``` + + + + +Then: + +```bash +npx poku +``` diff --git a/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/index.mdx b/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/index.mdx new file mode 100644 index 00000000..0ea8074a --- /dev/null +++ b/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/index.mdx @@ -0,0 +1,247 @@ +--- +title: Primeiros Passos +description: 🐷 Poku é seu Test Runner de Estimação para Node.js, Bun e Deno. +--- + +import Tabs from '@theme/Tabs'; +import TabItem from '@theme/TabItem'; +import { FAQ } from '@site/src/components/FAQ'; +import { Logo } from '@site/src/components/Logo'; +import { useColorMode } from '@docusaurus/theme-common'; +import Link from '@docusaurus/Link'; +import Success from '@site/static/img/success.svg'; +import '@site/src/css/features.scss'; + +[node-version-url]: https://github.com/nodejs/node +[node-version-image]: https://img.shields.io/badge/Node.js->=6.0.0-badc58 +[bun-version-url]: https://github.com/oven-sh/bun +[bun-version-image]: https://img.shields.io/badge/Bun->=0.5.3-f471b5 +[deno-version-url]: https://github.com/denoland/deno +[deno-version-image]: https://img.shields.io/badge/Deno->=1.30.0-70ffaf +[npm-image]: https://img.shields.io/npm/v/poku.svg?color=3dc1d3 +[npm-url]: https://npmjs.org/package/poku +[typescript-url]: https://github.com/microsoft/TypeScript +[typescript-version-image]: https://img.shields.io/badge/TypeScript->=5.0.2-3077c6 +[license-url]: https://github.com/wellwelwel/poku/blob/main/LICENSE +[license-image]: https://img.shields.io/npm/l/poku.svg?maxAge=2592000&color=9c88ff&label=Licença +[downloads-image]: https://img.shields.io/npm/dt/poku.svg?&color=FFC312&label=Downloads +[downloads-url]: https://npmjs.org/package/poku + +
+ + +
+ +
+ +## Por que usar o Poku? + +Ao criar o **Poku**, meu objetivo é mostrar que tests podem ser simples 🌱 + +
+
+ + Você não precisa aprender tudo de uma vez 🧑🏻‍🎓 +
+
+ + + Vamos tornar os `describe`, `beforeEach` e tudo mais ainda mais fáceis 🚀 + +
+
+ + + **Poku** traz testes e asserções amigáveis para + [**Node.js**][node-version-url], [**Bun**][bun-version-url] e + [**Deno**][deno-version-url] ao mesmo tempo ✨ + +
+
+ +
+ +> 🔬 Comece vendo como usar o `assert`
+> 🧪 Então aprenda a usar o `poku` no terminal para executar todos seus arquivos de uma vez só
+> 🧙🏻 Finalmente, apenas se você quiser, se aprofunde no aprendizado completo do **Poku**
+> +> 🩵 Leve seu tempo + +- [**Compare o Poku com os Test Runners mais Populares 🧪**](/docs/comparing) + +
+ +## Començando + +### **Instale** 📦 + +[![Install Size](https://packagephobia.com/badge?p=poku)](https://packagephobia.com/result?p=poku) + + + + +```bash +npm i -D poku +``` + + + + +```bash +npm i -D poku tsx +``` + + + + +```bash +bun add -d poku +``` + + + + +```ts +import { poku } from 'npm:poku'; +``` + +Você também pode usar o **Poku** via [**esm.sh**](https://esm.sh): + +```ts +import { poku } from 'https://esm.sh/poku'; +``` + + + + + +### **Teste** 🔬 + + + + +```ts +import { assert } from 'poku'; + +assert(true, 'Poku irá descrever isso 🐷'); +``` + + + + +### **Execute** 🚀 + + + + +```bash +npx poku +``` + + + + +```bash +bun poku +``` + + + + +```bash +deno run npm:poku +``` + + **Poku** requer as seguintes as seguintes permissões por padrão: + - `--allow-read` + - `--allow-env` + - `--allow-run` + + + + +### **É isso** 🎉 + +- [**Veja a documentação completa do `assert`**](/docs/documentation/assert). +- [**Veja a documentação completa do `poku`**](/docs/category/poku). + +
+ +## Documentação + +> Inicialmente, a [**documentação**](/docs/category/documentation) e [**exemplos**](/docs/category/examples) são baseados no **Node.js**, mas você pode usar tudo normalmente para **Bun** and **Deno**. + +
+ +## Comunidade + +Eu estou continuamente trabalhando para melhorar o **Poku**. Se você tem algo interessante para compartilhar, sinta-se à vontade para submeter um [**Pull Request**](https://github.com/wellwelwel/poku/compare). Se você percebeu algo estranho, eu apreciaria se você abrisse um [**Issue**](https://github.com/wellwelwel/poku/issues/new). + +
+ +## Contribuindo + +Verifique o [**CONTRIBUTING.md**](https://github.com/wellwelwel/poku/blob/main/CONTRIBUTING.md) para instruções 🚀 + +
+ +## Licença + +Poku está sob a [**Licença do MIT**](https://github.com/wellwelwel/poku/blob/main/LICENSE). + +
+ +## Política de Segurança + +Verifique o [**SECURITY.md**](https://github.com/wellwelwel/poku/blob/main/SECURITY.md) e a seção [**O Poku é Seguro?**](/docs/security) na Documentation. + +
+ +## Agradecimentos + +[![Contribuidores](https://img.shields.io/github/contributors/wellwelwel/poku?label=Contribuidores)](https://github.com/wellwelwel/poku/graphs/contributors) + +
+ Contribuidores + + +
+ +## Autor + + + wellwelwel +
+ @wellwelwel +
diff --git a/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/overview.mdx b/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/overview.mdx new file mode 100644 index 00000000..20be5ce3 --- /dev/null +++ b/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/overview.mdx @@ -0,0 +1,46 @@ +import SEQUENTIAL from '@site/static/img/sequential.png'; +import PARALLEL from '@site/static/img/parallel.png'; +import ASSERT_POKU from '@site/static/img/assert-poku.png'; +import ASSERT_NODE from '@site/static/img/assert-node.png'; + +# Visão Geral + +[bun-version-url]: https://github.com/oven-sh/bun +[deno-version-url]: https://github.com/denoland/deno + +| Sequencial | Concorrente | +| ------------------------ | ----------------------- | +| | | + +- Por padrão, o **Poku**: + - Procura por todos os arquivos _`.test.`_ e `.spec.`, mas você pode personalizar isso usando a opção [**`filter`**](/docs/documentation/poku/configs/filter). + - Usa o modo `sequencial`. +- Você pode usar concorrência ao definir a opção `--parallel` no terminal ou definindo a opção `parallel` como `true` ao usar a **API** (_in-code_). + +> Siga a mesma ideia para [**Bun**][bun-version-url] e [**Deno**][deno-version-url]. + +
+ +O **Poku** também inclui o método `assert`, mantendo tudo como sempre foi, mas providenciando fácil leitura humana e `describe` ou `it` automáticos: + +> Compatível com **Node.js**, **Bun** e **Deno**. + +```ts +import { assert } from 'poku'; // Node e Bun +import { assert } from 'npm:poku'; // Deno + +const actual = '1'; + +assert(actual, 'Meu primeiro assert'); +assert.deepStrictEqual(actual, 1, 'Meu primeiro erro com assert'); +``` + +| Usando `poku` | Usando `node` | +| -------------------------- | -------------------------- | +| | | + +- ❌ Ambos os casos finalizam com `código 1`, como esperado +- 🧑🏻‍🎓 O parâmetro `message` é opcional, assim como no **Node.js** +- 🐷 Diferente da maioria, o **Poku** é quem se adapta ao seu código, não o contrário + +> [**Veja a documentação completa do `asserr`**](/docs/documentation/assert). diff --git a/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/philosophy.mdx b/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/philosophy.mdx new file mode 100644 index 00000000..59678da5 --- /dev/null +++ b/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/philosophy.mdx @@ -0,0 +1,20 @@ +# Filosofia + +A filosofia do **Poku** foca em simplicidade e eficiência, eliminando complexidades para tornar os testes acessíveis do projeto mais simples ao mais complexo. + +O **Poku** dispensa novos aprendizados, pois adota o `assert` com a mesma usabilidade do **Node.js** e mantém a maioria dos recursos populares para test runners, além de ser naturalmente compatível com [**Node.js**][node-version-url], [**Bun**][bun-version-url] and [**Deno**][deno-version-url], incluindo versões antigas e ser **zero configurações** de verdade. + +Além disso, o **Poku** dispensa a dor de cabeça ao ter que lidar com ambientes diferentes como **CJS** e **ESM**, pois se adequa a qualquer ambiente (até mesmo [**TypeScript**][typescript-url] sem compilação quando somado ao [**tsx**][tsx]). + +Tamém, o **Poku** não usa um estado global, permitindo que você o utilize como e onde quiser. + +[![Install Size](https://packagephobia.com/badge?p=poku)](https://packagephobia.com/result?p=poku)
+É uma nuvem? Nada, é o **Poku**! Ele não só é leve, ele sequer possui dependências externas, permitindo que você só adicione recursos avançados somente quando realmente for necessário. + +Adote um **Poku** pra você 🐷 + +[node-version-url]: https://github.com/nodejs/node +[bun-version-url]: https://github.com/oven-sh/bun +[deno-version-url]: https://github.com/denoland/deno +[typescript-url]: https://github.com/microsoft/TypeScript +[tsx]: https://github.com/privatenumber/tsx diff --git a/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/security.mdx b/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/security.mdx new file mode 100644 index 00000000..be49ef12 --- /dev/null +++ b/website/i18n/pt-BR/docusaurus-plugin-content-docs/current/security.mdx @@ -0,0 +1,26 @@ +# O Poku é Seguro? + +O **Poku** é um projeto de código aberto, então você pode ver tanto o [Código Fonte no Repositório do **GitHub**](https://github.com/wellwelwel/poku) como o [Código de Distribuição no **NPM**](https://www.npmjs.com/package/poku?activeTab=code). + +## Por que o Poku usa o `child_process`? + +Alguns _Test Runners_ usam **`eval`**, o **Poku** prefere usar o **`spawn`** para criar um processo isolado seguramente para cada arquivo de teste. + +## Medidas de Proteção + +- Bloqueia o acesso acima do diretório atual filtrando os caminhos `../` e `/`, por exemplo: + - `/root` será sanitizado para `./root` + - `../../etc/secret` será sanitizado para `./etc/secret` +- Normaliza os caminhos de acordo com o sistema operacional, permitindo todos os colaboradores usarem o mesmo caminho, cada um com seu sistema operacional: + - `\` para **Windows** + - `/` para **Linux** e **macOS** +- Normaliza os caminhos ao filtrar caractéres incomuns para caminhos, por exemplo: + - `<>:|^?*` +- Previne _shell scripts_ ao definir `shell` como `false` no **`spawn`**, garantindo que apenas argumentos seguros serão usados. +- Cada **RegExp** é previamente testado usando o [**ReDoS Checker**](https://devina.io/redos-checker). + +## Política de Segurança + +:::info +Veja a [**Política de Segurança** no repositório do **GitHub**](https://github.com/wellwelwel/poku/blob/main/SECURITY.md). +::: diff --git a/website/package.json b/website/package.json index 886f7392..f4e23fe0 100644 --- a/website/package.json +++ b/website/package.json @@ -5,10 +5,11 @@ "scripts": { "docusaurus": "docusaurus", "start": "docusaurus start --host 0.0.0.0", + "start:br": "npm run start -- --locale pt-BR", "build": "docusaurus build", "swizzle": "docusaurus swizzle", "clear": "docusaurus clear", - "serve": "docusaurus serve", + "serve": "docker compose up --build", "write-translations": "docusaurus write-translations", "write-heading-ids": "docusaurus write-heading-ids", "typecheck": "tsc", diff --git a/website/server.ts b/website/server.ts index e8277420..d8887ba9 100644 --- a/website/server.ts +++ b/website/server.ts @@ -1,8 +1,18 @@ import { serve, file } from 'bun'; const publicDir = './build'; -const index = `${publicDir}/index.html`; -const docs = `${publicDir}/docs.html`; + +const paths = { + index: { + en: `${publicDir}/index.html`, + ptBR: `${publicDir}/pt-BR/index.html`, + }, + docs: { + en: `${publicDir}/docs.html`, + ptBR: `${publicDir}/pt-BR/docs.html`, + }, +}; + const port = process.env.APP_PORT; const setCache = (filePath: string): string => { @@ -35,6 +45,11 @@ serve({ }); } + const index = pathname.includes('pt-BR') + ? paths.index.ptBR + : paths.index.en; + + const docs = pathname.includes('pt-BR') ? paths.docs.ptBR : paths.docs.en; const page = pathname.includes('/docs') ? docs : index; return new Response(file(page).stream(), {