https://github.com/sevenc-nanashi/cross-test
A test runner for Deno that allows you to run tests in multiple JS runtimes.
https://github.com/sevenc-nanashi/cross-test
deno
Last synced: 5 months ago
JSON representation
A test runner for Deno that allows you to run tests in multiple JS runtimes.
- Host: GitHub
- URL: https://github.com/sevenc-nanashi/cross-test
- Owner: sevenc-nanashi
- License: mit
- Created: 2024-08-11T06:21:07.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-09-02T21:00:38.000Z (almost 2 years ago)
- Last Synced: 2025-04-10T23:14:28.482Z (about 1 year ago)
- Topics: deno
- Language: TypeScript
- Homepage:
- Size: 148 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Cross-test / Cross test runner for Deno
Cross-test is a test runner for Deno that allows you to run tests in multiple JS
runtimes.
> [!IMPORTANT]
> This is very experimental plugin; it may not work as expected.
## Supported runtimes
- Deno
- Node.js
- Bun
- Workerd (aka: Cloudflare Workers)
- Browser
## Installation
```sh
$ deno add @sevenc-nanashi/cross-test
```
For GitHub Actions setup:
```yml
- name: Checkout
uses: actions/checkout@v4
- name: Setup Deno
uses: denoland/setup-deno@v1
with:
deno-version: v1.x
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Setup Bun
uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- name: Cache
uses: actions/cache@v4
with:
path: ~/.cache/cross-test/workerd-manager
key: ${{ runner.os }}-cross-test-workerd-manager
- name: Run tests
run: deno test -A ./example
```
## Usage
```ts
import { createCrossTest } from "@sevenc-nanashi/cross-test";
const crossTest = createCrossTest({
runtimes: ["deno", "node", "bun", "workerd", "browser"],
});
crossTest("My Test", () => {
// Your test code here will be run in these 5 runtimes.
});
```
## How does it work?
- Deno: It runs the test code in the Deno runtime.
- Node.js, Bun:
- Compile the test code to ESM using `esbuild`.
- Run the compiled code in the Node.js or Bun runtime.
- Workerd:
- Create a Node project which runs miniflare, a local emulator of Cloudflare Workers.
- Compile the test code to ESM using `esbuild`.
- Run the compiled code in the Workerd runtime via the created Node project.
- Browser:
- Compile the test code to ESM using `esbuild`.
- Run the compiled code in the Browser runtime via [`@astral/astral`](https://jsr.io/@astral/astral)
## License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file
for details.