-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
65 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,12 @@ jobs: | |
steps: | ||
- name: Git Checkout | ||
uses: actions/checkout@v3 | ||
- name: Use Bun Version ${{ matrix.bun-version }} | ||
uses: antongolub/[email protected] | ||
with: | ||
bun-version: ${{ matrix.bun-version }} | ||
bun-repo: 'oven-sh/bun' | ||
- name: Install Dependencies | ||
run: bunx jsr add @cross/test @std/assert | ||
run: bun x jsr add @cross/runtime @cross/test @std/assert | ||
- name: Test Bun Module | ||
run: bun test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,6 @@ | |
|
||
name: Node.js CI | ||
|
||
disabled: true | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,90 @@ | ||
## Cross-runtime testing framework for Deno, Bun, and Node.js | ||
## Cross-runtime Testing for Deno, Bun, and Node.js | ||
|
||
[](https://jsr.io/@cross/test) [](https://jsr.io/@cross/test/score) | ||
|
||
**Work in progress** | ||
**A minimal testing framework designed for seamless use across Deno, Bun, and Node.js. Works great with @std/assert and @std/expect for assertions.** | ||
|
||
Truly cross runtime minimal testing framework working in collaboration with @std/assert, for Node, Deno and Bun. | ||
**Installation** | ||
|
||
## Install | ||
1. **Install `@cross/test` and `@std/assert`:** | ||
|
||
Node: | ||
```bash | ||
# Pick your runtime and package manager: | ||
npx jsr add @cross/test @std/assert # Node.js | ||
deno add @cross/test @std/assert # Deno | ||
bunx jsr add @cross/test @std/assert # Bun | ||
``` | ||
|
||
``` | ||
npx jsr add @cross/test @std/assert | ||
``` | ||
|
||
Deno: | ||
|
||
``` | ||
deno add @cross/test @std/assert | ||
``` | ||
|
||
Bun: | ||
|
||
``` | ||
bunx jsr add @cross/test @std/assert | ||
``` | ||
**Example** | ||
|
||
## Example | ||
|
||
my.test.js | ||
|
||
```js | ||
```javascript | ||
import { test } from "@cross/test"; | ||
import { assertEquals, assertNotEquals } from "@std/assert"; | ||
|
||
// Simple test | ||
test("Multiplication", () => { | ||
assertEquals(5 * 4, 20); | ||
}); | ||
|
||
// Simple test with timeout | ||
test("Multiplication with timeout", () => { | ||
assertEquals(5 * 4, 20); | ||
}, { timeout: 1000 }); | ||
|
||
// Test with completion callback | ||
test("Async test", (_context, done) => { | ||
setTimeout(() => { | ||
assertNotEquals(5, 4); | ||
done(); // Signal test completion | ||
done(); | ||
}, 500); | ||
}, { waitForCallback: true }); | ||
``` | ||
|
||
## Running the tests | ||
**Running Tests** | ||
|
||
- **Directly in your runtime:** | ||
- **Node.js:** `node --test` | ||
- **Deno:** `deno test` | ||
- **Bun:** `bun test` | ||
|
||
**CI Integration** | ||
|
||
To avoid cluttering with unnessecary files, use CI to test Node and Bun if you develop using Deno, and vice versa. Below is some example on `.github/workflows/runtime.yml` for automated testing on | ||
GitHub. | ||
|
||
Node: | ||
**Example CI Configurations** | ||
|
||
`node --test` | ||
- **Bun (GitHub Actions):** | ||
|
||
Deno: | ||
```yaml | ||
name: Bun CI | ||
|
||
`deno test` | ||
on: [push, pull_request] | ||
|
||
Bun: | ||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: antongolub/[email protected] | ||
with: | ||
bun-version: v1.x # Uses latest bun 1 | ||
- run: bun x jsr add @cross/test @std/assert # Installs dependencies | ||
- run: bun test # Runs the tests | ||
``` | ||
- **Deno (GitHub Actions):** | ||
```yaml | ||
name: Deno CI | ||
|
||
`bun test` | ||
on: [push, pull_request] | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: denoland/setup-deno@v1 | ||
with: | ||
deno-version: v1.x # Uses latest deno version 1 | ||
- run: deno add @cross/test @std/assert # Installs dependencies from jsr.io | ||
- run: deno test # Runs tests | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters