Skip to main content
Home

latest
It is unknown whether this package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
It is unknown whether this package works with Cloudflare Workers
It is unknown whether this package works with Node.js
It is unknown whether this package works with Deno
It is unknown whether this package works with Bun
It is unknown whether this package works with Browsers
JSR Score
82%
Published
a week ago (0.6.3)

suite

NPM Version JSR

Describe tests that run in the native test runners of Node.js, Deno and Bun.

example

// 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

/** 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>): 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
  }
}

New Ticket: Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@hongminhee/suite

Import symbol

import * as suite from "@hongminhee/suite";
or

Import directly with a jsr specifier

import * as suite from "jsr:@hongminhee/suite";

Add Package

pnpm i jsr:@hongminhee/suite
or (using pnpm 10.8 or older)
pnpm dlx jsr add @hongminhee/suite

Import symbol

import * as suite from "@hongminhee/suite";

Add Package

yarn add jsr:@hongminhee/suite
or (using Yarn 4.8 or older)
yarn dlx jsr add @hongminhee/suite

Import symbol

import * as suite from "@hongminhee/suite";

Add Package

vlt install jsr:@hongminhee/suite

Import symbol

import * as suite from "@hongminhee/suite";

Add Package

npx jsr add @hongminhee/suite

Import symbol

import * as suite from "@hongminhee/suite";

Add Package

bunx jsr add @hongminhee/suite

Import symbol

import * as suite from "@hongminhee/suite";