https://github.com/alineacms/suite
Describe tests that run in the native test runners of Node.js, Deno and Bun.
https://github.com/alineacms/suite
bun deno node test
Last synced: about 2 months ago
JSON representation
Describe tests that run in the native test runners of Node.js, Deno and Bun.
- Host: GitHub
- URL: https://github.com/alineacms/suite
- Owner: alineacms
- License: mit
- Created: 2024-06-06T11:24:37.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2025-06-12T12:56:47.000Z (about 1 year ago)
- Last Synced: 2025-06-25T03:40:23.534Z (about 1 year ago)
- Topics: bun, deno, node, test
- Language: JavaScript
- Homepage:
- Size: 57.6 KB
- Stars: 3
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# suite
[](https://www.npmjs.com/package/@alinea/suite)
[](https://jsr.io/@alinea/suite)
Describe tests that run in the native test runners of Node.js, Deno and Bun.
## example
````ts
// example.test.js
import {suite} from '@alinea/suite'
const test = suite(import.meta)
test('is', () => {
test.is(1, 1)
})
test('deep equal', () => {
test.equal({a: 1}, {a: 1})
})
test('async', async () => {
await new Promise(resolve => setTimeout(resolve, 100))
test.ok(true)
})
test('throws', () => {
test.throws(() => {
throw new Error('test')
}, 'test')
})
test.skip('skip', () => {
test.ok(false)
})
````
Run with:
- `node --test`
- `bun test`
- `deno test`
## api
````ts
/** Define a test suite */
export function suite(meta: ImportMeta): (test: DefineTest) => void
export function suite(meta: ImportMeta, define: (test: DefineTest) => void): void
/** Describe a test */
export type Describe =
(name: string, run: () => void | Promise): void
/** Define a test suite */
export interface DefineTest extends Describe {
/** Skip the test */
skip: Describe
/** Only run this test */
only: Describe
/** Assert that actual is a truthy value */
ok(actual: any): void
/** Assert that actual strictly equals (===) the expects value */
is(actual: any, expects: any): void
/** Assert that actual is deeply equal to the expects value */
equal(actual: any, expects: any): void
/** Assert that the fn function throws an Error */
throws(fn: () => void, messageIncludes?: string): void
/** Assert inverse */
not: {
/** Assert that actual is a falsy value */
ok(actual: any): void
/** Assert that actual does not strictly equal (===) the expects value */
is(actual: any, expects: any): void
/** Assert that actual is not deeply equal to the expects value */
equal(actual: any, expects: any): void
}
}
````