Skip to content

Commit

Permalink
feat: innovating beforeEach and afterEach (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
wellwelwel committed Feb 29, 2024
1 parent 6925383 commit 3ea3a12
Show file tree
Hide file tree
Showing 32 changed files with 1,072 additions and 107 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"eqeqeq": [2, "always"],
"no-var": 2,
"block-scoped-var": 2,
"no-async-promise-executor": 2,
"no-async-promise-executor": "off",
"no-bitwise": [2, { "allow": ["~"] }],
"no-duplicate-imports": [2, { "includeExports": true }],
"no-eq-null": 2,
Expand Down
9 changes: 5 additions & 4 deletions .github/workflows/ci-website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ on:
- 'website/**'
workflow_dispatch:

env:
APP_PORT: ${{secrets.APP_PORT}}

jobs:
build:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -44,8 +41,12 @@ jobs:

- name: Checking Docker Build
run: cd website && docker compose up -d --build
env:
APP_PORT: ${{secrets.APP_PORT}}

- name: Checking for Service Status Header
run: |
sleep 1
curl --fail --silent --output /dev/null http://localhost:3000
curl --fail --silent --output /dev/null http://localhost:${{ env.APP_PORT }}
env:
APP_PORT: ${{secrets.APP_PORT}}
19 changes: 11 additions & 8 deletions .github/workflows/docs-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@ on:
- 'website/**'
workflow_dispatch:

env:
SRV_HOST: ${{secrets.SRV_HOST}}
SRV_USER: ${{secrets.SRV_USER}}
SRV_PORT: ${{secrets.SRV_PORT}}
SRV_PASS: ${{secrets.SRV_PASS}}
APP_PORT: ${{secrets.APP_PORT}}

jobs:
deploy:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -47,11 +40,21 @@ jobs:

- name: Checking Docker Build
run: cd website && docker compose up -d --build
env:
APP_PORT: ${{secrets.APP_PORT}}

- name: Checking for Service Status Header
run: |
sleep 1
curl --fail --silent --output /dev/null http://localhost:3000
curl --fail --silent --output /dev/null http://localhost:${{ env.APP_PORT }}
env:
APP_PORT: ${{secrets.APP_PORT}}

- name: Deploy
run: cd website && npm run deploy
env:
SRV_HOST: ${{secrets.SRV_HOST}}
SRV_USER: ${{secrets.SRV_USER}}
SRV_PORT: ${{secrets.SRV_PORT}}
SRV_PASS: ${{secrets.SRV_PASS}}
APP_PORT: ${{secrets.APP_PORT}}
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
[ql-image]: https://img.shields.io/github/actions/workflow/status/wellwelwel/poku/codeql.yml?event=push&style=flat&label=Code%20QL&branch=main
[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=License
[downloads-image]: https://img.shields.io/npm/dt/poku.svg?&color=FFC312&label=Downloads
[downloads-url]: https://npmjs.org/package/poku

# Poku

Expand All @@ -27,6 +29,7 @@
[![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 ⭐️
Expand All @@ -39,7 +42,7 @@ Enjoying **Poku**? Consider giving him a star ⭐️

## Why Poku?

Let's make `describe`, `beforeEach` and everything else easier ([**see why and how**](https://poku.dev/docs/examples/beforeEach)) 🚀 <br/>
Let's make `describe`, `beforeEach` and everything else easier 🚀 <br/>

- Supports **ESM** and **CJS**
- Designed to be highly intuitive
Expand Down
28 changes: 28 additions & 0 deletions src/@types/poku.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,32 @@ export type Configs = {
* @default 'node'
*/
platform?: 'node' | 'bun' | 'deno';
/**
* You can use this option to run a **callback** or a **file** before each test file on your suite.
*
* Ex.:
*
* ```ts
* beforeEach(prepare)
* ```
*
* ```ts
* beforeEach('/tools/prepare.ts')
* ```
*/
beforeEach?: () => unknown | Promise<unknown>;
/**
* You can use this option to run a **callback** or a **file** after each test file on your suite.
*
* Ex.:
*
* ```ts
* afterEach(cleanup)
* ```
*
* ```ts
* afterEach('/tools/cleanup.ts')
* ```
*/
afterEach?: () => unknown | Promise<unknown>;
} & ListFilesConfigs;
1 change: 1 addition & 0 deletions src/helpers/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const format = {
bold: (value: string) => `\x1b[1m${value}\x1b[0m`,
underline: (value: string) => `\x1b[4m${value}\x1b[0m`,
info: (value: string) => `\x1b[94m${value}\x1b[0m`,
italic: (value: string) => `\x1b[3m${value}\x1b[0m`,
success: (value: string) => `\x1b[32m${value}\x1b[0m`,
fail: (value: string) => `\x1b[91m${value}\x1b[0m`,
bg: (bg: number, text: string) => {
Expand Down
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
export { poku } from './modules/poku.js';
export { exit } from './modules/exit.js';
export { assert } from './modules/assert.js';
export { assertPromise } from './modules/assert-promise.js';
export { beforeEach, afterEach } from './modules/each.js';
export { publicListFiles as listFiles } from './modules/list-files.js';
export type { Code } from './@types/code.ts';
export type { Configs } from './@types/poku.ts';
Expand Down
Loading

0 comments on commit 3ea3a12

Please sign in to comment.