Skip to content

Commit

Permalink
Fix bun CI
Browse files Browse the repository at this point in the history
  • Loading branch information
Hexagon committed Mar 11, 2024
1 parent 33e4746 commit 32f7075
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 40 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/bun.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 0 additions & 2 deletions .github/workflows/node.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

name: Node.js CI

disabled: true

on:
push:
branches: [ main ]
Expand Down
94 changes: 58 additions & 36 deletions README.md
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

[![JSR Version](https://jsr.io/badges/@cross/test)](https://jsr.io/@cross/test) [![JSR Score](https://jsr.io/badges/@cross/test/score)](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
```
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cross/test",
"version": "0.0.7",
"version": "0.0.6",
"exports": "./mod.ts",
"fmt": {
"lineWidth": 200
Expand Down

0 comments on commit 32f7075

Please sign in to comment.