Skip to content

Supported syntax ​

This reference covers all frameworks. For a scan command, example and syntax for just your runner, choose a framework guide. Shared syntax is under In every runner.

Choose your runner below for imports, common declarations and version-specific forms. The tables describe what the scanner recognizes; they do not execute these calls. Start with the examples for complete setups and key concepts for the meaning of states, cases and projects.

Across runners, a test or describe callback may be a function written inside a wrapper call, as in test('fills an order', withBroker(async () => {})): when the call receives exactly one function, that function is read as the body, its parameters being the wrapper's and not fixtures. A describe callback may also be a function or arrow declared in the file and passed by name. Its tests inherit the calling suite's state and metadata, and its closed-over values come from where the function is declared. Vitest, Jest and Bun describe tables bind each expanded case's arguments to the named callback. Imported describe callbacks are not followed.

Playwright ​

Playwright 1.31 and newer.

Where test comes from ​

FormExample
Named import, also renamedimport { test } from '@playwright/test', import { test as base } from '@playwright/test'
Default importimport pwTest from '@playwright/test'
Namespace importimport * as pw from '@playwright/test' then pw.test(...)
CommonJSconst { test } = require('@playwright/test'), require('@playwright/test').test(...)
Other packagesplaywright/test, @playwright/experimental-ct-react and the other component testing packages, and playwright-bdd, whose generated files import test from it
Derivedbase.extend({...}), chained .extend().extend(), mergeTests(a, b)
Kept in a variableconst later = test.skip: keeps skip, fixme, fail, only or fail.only. Conditional and logical choices, also written inline, keep only the modifiers every possible test function shares.
Local fixtures fileimport { test } from '../fixtures', or a path alias, # import or workspace package, followed through re-exports, extend chains and functions that build it, across files
Returned by a functionbrokerTest('live')('sends an order', ...), also kept in a variable, where brokerTest is declared in the file or a local file and returns a test object or describe function
Destructured membersconst { describe, beforeEach } = test, also nested, as in const { describe: { serial } } = test: each works as test.describe or test.beforeEach does. A test object built with a destructured extend is not followed

Calls ​

CallRead as
test(title, body), test(title, details, body)A test. The body may be a function passed by name or one a wrapper call receives. Before Playwright 1.42 details are an invalid-chain warning: Playwright takes them for the body, so the test fails and has none of their tags.
test.only, test.skip, test.fixme, test.fail with a title and bodyA test with that state. The body may be a function passed by name, whatever the title is. Before Playwright 1.42, test.fail(title, body), and skip, fixme or fail with details, declare no test: the title is a condition for every test in the scope, with a skip-without-body warning.
test.fail.onlyExpected to fail, with isOnly. Playwright 1.49 and newer.
test.skip(), test.skip(condition, description), test.skip(({ browserName }) => condition, description); the same for fixme and failAt file or describe level, a state for every test in the scope. In a test body or hook, a state for that test or the tests the hook runs for.
test.skip(description) with a string, from Playwright 1.65; the same for fixme and failThe same, with the string as the reason; an empty string applies nothing. Before 1.65 the string is only a condition, with a skip-without-body warning.
test.describe(title, callback), with details, or anonymous test.describe(callback)A describe. Before Playwright 1.42 a describe with details is an invalid-chain error, as the call throws.
test.describe.only, .skip, .fixme, .serial, .serial.only, .parallel, .parallel.onlyA describe with that state or mode.
test.describe.configure({ mode, lock })The mode of the describe or file. lock, from Playwright 1.64, adds locks to every test in it.
test.info().annotations.push({ type, description })An annotation of the test.
test.use, test.slow, test.setTimeout, test.step, test.step.skip (1.50), test.expect, test.info, test.abort (1.60), hooksKnown; not tests.
Any other chain, such as test.only.skipAn invalid-chain error: Playwright fails to load the file and runs no tests at all.

Details ​

{ tag, annotation, lock }: tag is a string or an array of strings starting with @; annotation an object or an array of { type, description }; lock a string or an array of strings, from Playwright 1.63. Tags are also read from @words in titles. Before Playwright 1.42 a test has only the tags of its own title, as Playwright's report gives them, and a describe has none.

Vitest ​

Vitest 1.0 and newer. test.for came in Vitest 2.0 and describe.for in 3.0; before, each is an invalid-chain error, as the call throws and Vitest fails the file.

Where test comes from ​

FormExample
Named import, also renamedimport { test, it, describe, suite } from 'vitest'
Namespace importimport * as vt from 'vitest' then vt.test(...)
Globalsdescribe, it, test and suite used without an import or declaration. A warning says when no config turns globals on.
In-source testsconst { it, describe } = import.meta.vitest
Describe callbackdescribe('fees', (test) => { test(...) }): Vitest passes its test to the callback
Derivedtest.extend({...}), test.extend('name', value), chained; test.override() and test.scoped() are known
Local fixtures fileimport { test } from './context', or a path alias, # import or workspace package, followed through re-exports, extend chains and functions that build it, across files
Returned by a functiononNode(22)('reads the order book', ...), also kept in a variable, where onNode is declared in the file or a local file and returns a test or describe function, as in it.skip
Destructured membersconst { describe, skip, beforeEach } = test: each works as test.describe or test.skip does. Some members read the function they are called on, so a call through one destructured fails the file, reported as invalid-chain: each, for, skipIf and runIf of test and each of describe in every version, extend, scoped and override from Vitest 4.1, and for of describe from Vitest 5
Kept in a variableconst onCi = process.env.CI ? test.skip : test: only what both branches share applies, also to a choice written in place, as (process.env.CI ? test.skip : test)(...)

Calls ​

CallRead as
test(title, fn), test(title, options, fn), test(title, fn, timeout)A test. Without a function, a todo.
test(title, fn, options)Accepted before Vitest 4; a removed-api error from Vitest 4.
.concurrent, .only, .skip, .todo, .fails, before a called .each or .for.only wins over .skip, which wins over .todo.
.each(table), .for(table), also as tagged templatesOne parameterized record, with caseCount when the scan can work out the table; one record per case with --expand-cases.
.skipIf(condition), .runIf(condition)A conditional skip. runIf(x) is stored as the condition !(x).
describe with .concurrent, .shuffle, .skip, .only, .todo, .each, .for, .skipIf, .runIfA describe. describe(title) without a function is a todo.
describe(fn) without a titleA describe-not-called error: Vitest never calls the function.
context.skip(), skip(note), skip(condition, note) in a test, beforeEach or aroundEachA state for that test, or for the tests in the describe.
Options skip, only, todo, fails, concurrent, sequential, shuffle, tags (4.1), metaRead from the file. A test's own states win over its chain. Vitest 5 ignores the sequential option.
// @module-tag nameA tag on every test in the file, from Vitest 4.1.
.sequentialThe default mode before Vitest 5; a removed-api error from Vitest 5.
bench(...), with bench imported from vitestA removed-api error from Vitest 5. Benchmarks are never tests.
vi.mock, vi.unmock, vi.hoisted below the top level of the fileA removed-api error from Vitest 5, except in files with in-source tests.
Any other chain, such as test.fixmeAn invalid-chain error.

Jest ​

Jest 27.0 and newer.

Where test comes from ​

FormExample
Globalsdescribe, it, test, fit, xit, xtest, fdescribe and xdescribe used without an import or declaration
Named import, also renamedimport { test, it, describe, xit } from '@jest/globals'
The moduleimport * as globals from '@jest/globals', a default import (with Babel or TypeScript), or require('@jest/globals'), whole, destructured or in place
Kept in a variableconst onCi = process.env.CI ? test.skip : test: only what both branches share applies, also to a choice written in place, as (process.env.CI ? test.skip : test)(...)
Local helpers fileimport { it } from './helpers' or require('./helpers'), followed through local imports, a global it exports, as export const pendingTest = xit, and functions that return a test function

fit and fdescribe are .only; xit, xtest and xdescribe are .skip. As in Jest, a describe's own .only or .skip wins over the one around it, a skipped describe skips every test in it, a todo or a .only too, and in a describe.only that has a test with its own .only, its other tests are left out of focus. A file that uses the globals while its config sets injectGlobals: false gets a globals-not-enabled warning.

Calls ​

CallRead as
test(title, fn), test(title, fn, timeout)A test, with timeout when the third argument is a number the scan can work out.
test.todo(title)A todo. Jest requires exactly one string argument. An invalid call reports invalid-chain and the file fails to load.
test(title), describe(title) without a functionA test-without-body error: Jest fails the file.
.only, .skip, .concurrent, .failing, .each, on the paths Jest hastest.concurrent.only.each exists, test.only.concurrent doesn't and is an invalid-chain error. .failing is expectedToFail; before Jest 28 it is an invalid-chain error.
.each(table), also as a tagged templateOne parameterized record, with caseCount; one record per case with --expand-cases, titled as jest-each titles it.
describe, describe.only, describe.skip, describe.eachA describe. An async callback is an async-describe error: Jest fails the file.
test.each(table)(title) without a functionThe scan warns about the callback. Ordinary tables register one fallback test. Concurrent and failing tables can register every row. See Jest.
test(title, 42, fn), describe(title, {}, fn)A test-without-body error: Jest takes the function second, and fails the file.
A describe callback that returns a value, or a describe.each with an empty tableA describe-throws error: Jest fails the file. A callback that returns a promise is an async-describe error.
jest.retryTimes(n)retries on every test of the file: the last call made while the file loads wins, also from inside a describe.
jest.retryTimes(n, { entireDescribe: true })From Jest 30.5, retries on the tests of the describe it is called in.
jest.retryTimes(n, { waitBeforeRetry })From Jest 30.0, the wait between retries as retryDelay.
@group name in a commentA tag on every test in the file, as jest-runner-groups reads it: any line of the file that starts with @group, after a comment's *.

Jest's .each titles take %p, %s, %d, %i, %f, %j, %o, %O, %#, from Jest 30 %$, and $name.path and $# for tables of objects and tagged templates. A title that shows an object through %s or %o stays one record with --expand-cases, as Node.js prints objects differently from one version to the next.

Mocha ​

Mocha 10.0 and newer.

Where test comes from ​

FormExample
Globalsdescribe, context, it, specify, xdescribe, xcontext, xit and xspecify used without an import or declaration; with ui: tdd in the config, suite and test
Named import, also renamedimport { describe, it } from 'mocha'
The moduleimport * as mocha from 'mocha', a default import, or require('mocha'), whole, destructured or in place
Kept in a variableconst onCi = process.env.CI ? it.skip : it: only what both branches share applies, also to a choice written in place, as (process.env.CI ? it.skip : it)(...)
Local helpers fileimport { it } from './helpers' or require('./helpers'), followed through local imports, and helper functions that declare tests, read at each call

xit, xspecify, xdescribe and xcontext are .skip. Mocha's QUnit and exports interfaces, and a ui that names a package, are reported on the config with a config-value-unknown warning, and the files are read as BDD.

Calls ​

CallRead as
it(title, fn), specify(title, fn)A test.
it(title) without a functionA skipped test: Mocha reports it as pending.
.only, .skipisOnly, or a skipped test or describe. Any other member, as it.concurrent, is an invalid-chain error: Mocha stops before it runs any test, in this file or any other.
describe(title, fn), context(title, fn)A describe. An async callback is allowed, as Mocha allows it.
describe(title) without a functionA test-without-body error: Mocha stops before it runs any test. describe.skip(title) is allowed.
it(), describe() without a titleA test-without-body error: Mocha stops before it runs any test.
before, after, beforeEach, afterEach, with or without a titleHooks, counted as beforeAll, afterAll, beforeEach and afterEach; with ui: tdd, suiteSetup, suiteTeardown, setup and teardown.
this.timeout(ms), this.retries(n) in a describe written as a functiontimeout and retries on its tests and those of the describes inside it. A timeout may be a number or a string such as '2s'; 0, and one of 2,147,483,647 ms or more, turns it off.
this.timeout(ms), this.retries(n) in a test written as a functionThe test's own timeout and retries. In a hook, this.timeout() sets the hook's own timeout, which no record holds.
it(...).timeout(ms), it(...).retries(n), describe(...).timeout(ms)The same settings on the test the call returns. On a describe, only the timeout, and only from Mocha 12, which reads it as each test runs; before, a describe's tests take its timeout when they are added. describe(...).retries(n) reaches none of its tests.
this.skip() in a test or a before or beforeEach hook written as a functionThe test, or the tests the hook runs for, skipped; under a condition, isConditional.

this is Mocha's context only directly in the test's, hook's or describe's own function: in an arrow function, or a function inside it, this.timeout() and this.skip() are not read. A test takes its describe's retries, and before Mocha 12 its timeout, when it is added, so a test written above this.retries() in the same describe doesn't get them; the scan applies them to every test of the describe. A beforeEach or other hook written at the top level of one spec file runs around the tests of every file, but is counted only in that file. A loop that declares tests, such as ['XNAS', 'XLON'].forEach((mic) => it(...)), is one record with caseCount, as for the other runners. Root hooks, which a file the config lists in require exports as mochaHooks, run around every test, but are not counted in hooks; the file is in each test's dependencies.

Jasmine ​

Jasmine 3.0 and newer.

Where test comes from ​

FormExample
Globalsdescribe, xdescribe, fdescribe, it, xit and fit, which the jasmine command, Karma or a browser page set; Jasmine has no module to import them from
Kept in a variableconst later = xit: the variable keeps the x or f; of a choice, also one written in place, as (process.env.CI ? xit : it)(...), only what both branches share applies
Local helpers fileimport { spec } from './helpers' or require('./helpers'), followed through local imports, and helper functions that declare specs, read at each call

xit and xdescribe are .skip, and fit and fdescribe .only. Jasmine's functions have no members, so a call such as it.only() is an invalid-chain error. Jasmine runs the innermost focus: a fit or fdescribe runs also inside an xdescribe, while an xdescribe inside an fdescribe stays skipped, and in an fdescribe with a fit or fdescribe below it, only those run, so its other specs have isOnly: false. WebdriverIO on Jasmine follows the same rules.

Calls ​

CallRead as
it(title, fn), it(title, fn, timeout)A spec, with timeout when the third argument is a number the scan can work out.
it(title), xit(title) without a function, or with undefinedA skipped spec: Jasmine reports it as pending; it() is one titled ''. fit(title) without one is a test-without-body error.
it(title, 42)A test-without-body error: Jasmine takes the function second.
describe(title, fn)Jasmine requires a function (test-without-body). It rejects async callbacks (async-describe) and generator callbacks (describe-throws). A plain describe also rejects a callback with length above 0, such as (fills) => {}.
beforeAll, beforeEach, afterEach, afterAllHooks, also with a timeout as their second argument.
pending(reason) in a spec, beforeEach or afterEachThe spec skipped with the reason; under a condition, isConditional. In beforeAll or afterAll, Jasmine reports it as an error of the describe, and the specs keep their state.
notApplicable(reason) in a specFrom Jasmine 7, the spec skipped with the reason. Before, the call fails the spec.

For it, xit and fit, the scan reads the title, callback and timeout in argument order, including values supplied through array or string spreads. Jasmine rejects generator callbacks, including async generators. From 3.10 it also rejects a timeout greater than 2,147,483,647, even for a pending spec. JavaScript evaluates extra arguments before Jasmine checks the callback and timeout.

Jasmine takes the hook callback first and an optional timeout second. A missing callback, a nonfunction or a generator raises invalid-hook during registration. From Jasmine 3.10, a timeout above 2,147,483,647 also throws. The scan reads callback and timeout positions across literal spreads and unchanged array constants. Extra arguments are evaluated before the hook is registered.

Jasmine 3 accepts empty suites. From 4.0, a plain describe that registers no spec or child suite is a describe-throws error, including when it declares only hooks. From 4.5 this also applies to xdescribe and fdescribe. Both accept callbacks with unused positional arguments.

The scan also recognizes an empty suite when its only spec is inside an uncalled function, follows an unconditional return, or sits in a branch guarded by a false literal or local constant. It follows calls to local helpers with the arguments supplied. A spec registered by a parameter default counts as a child, as does a nested suite whose empty-suite error the parent catches. When the scan cannot determine whether a call registered a child, it keeps later registrations in the inventory.

An uncaught registration error at the top level of a file stops Jasmine before it runs any spec, in this file or any other, and every test in the file is notLoaded. Inside a describe, Jasmine catches errors that escape its callback. The scan marks subsequent specs in that callback notLoaded, including registrations made through helpers. Earlier specs and sibling suites keep their states. A user-written catch can resume collection, and finally can register specs before the error escapes. The same recovery rules apply to a top-level try in the spec file. The scan omits a catch block when it can establish that the preceding try completes normally. Calls with unknown side effects keep recovery specs in the inventory. Jasmine test and suite titles can come from local function calls. The scan follows the return reached with the supplied arguments, including a return in a finally block that overrides an earlier one. When a title combines helper results, the scan follows arithmetic, string interpolation, comparisons, and the branch JavaScript selects in a logical or conditional expression. A helper can return a title built with string case conversion, trim(), array join(), String(), Object.keys/values/entries() or JSON.stringify() when the receiver and arguments resolve. For example, a successfully registered spec or suite returns a truthy object, while a hook returns undefined. An unresolved title keeps its source text. Jasmine uses an empty spec name for false, zero, null and undefined. Suite paths preserve false and zero as text.

Jasmine formats resolved array elements as a comma-separated description, including elements from local helper calls and spreads. A hole, null or undefined contributes an empty field. For example, ['cash', null, ['desk', 7]] gives the title cash,,desk,7. Resolved data objects that inherit the default string conversion give [object Object], including when they appear inside arrays.

Jasmine stops evaluating a registration call at a noniterable spread operand, including a local helper that returns a number, a promise, an async generator object, or the result of registering a Jasmine spec or suite. Earlier registrations stand, and an enclosing catch handles the failure. A Jasmine suite reads its first two arguments as the title and callback, including when a literal array or a local constant supplies them through a spread. Named callbacks keep the bindings from their definition. When a synchronous helper registers specs while evaluating arguments to a Jasmine declaration, those specs belong to the enclosing suite. If an argument throws, Jasmine skips the remaining arguments and the declaration itself. A helper's default parameter initializer runs for a missing or undefined value. The scan follows defaults through literal arrays, objects and known spread arguments. Array patterns read strings one Unicode code point at a time. Object patterns can read character positions and the length property from strings and arrays. If a known value cannot be destructured or spread into a call or array, the scan keeps specs registered before the failure. An async function returns a rejected promise for a parameter binding error. An invalid spread in the caller throws before the async function starts. These rules also apply when the file or a suite calls a helper directly. Calling a generator binds its parameters immediately and defers its body until iteration. When a registration argument spreads a direct synchronous generator call, the scan follows its body in order. Yielded values feed the receiving call, and a throw during iteration prevents later arguments from registering specs. The first full spread of a saved synchronous generator runs its body at the spread site. A second spread through the same constant or an alias supplies no arguments. For a saved iterator, each explicit next() runs registrations up to the next supported yield. A later next(value) supplies the value of that suspended expression in a simple variable initializer, a return, an if test or an argument to a named function. Earlier arguments run before the pause. A spread reads the remaining yields and resumes each with undefined. The scan follows return() and throw() through catch and finally blocks and reads known value and done properties from the result. Titles can also use yielded operands in arithmetic and template strings. When a condition is known, only the selected operand of ?:, &&, || or ?? can register specs or pause the iterator. When yield* inner delegates to another known synchronous generator, calls to next, return and throw advance that same inner iterator. On normal completion, the surrounding expression receives the inner generator's return value. Inside a generator's catch, a title can use a known thrown value, including one sent by iterator.throw(value). A catch binding survives later yields in that handler. Object and array patterns can extract fields from the thrown value. From Jasmine 4.5, an empty-suite error leaves that suite open. Specs registered by a catch or finally then belong to the empty suite and inherit its hooks and focus or skip settings. If a helper catches that error while evaluating a declaration argument, the declaration itself also belongs to the suite that is open when Jasmine receives the call. An async helper can change that suite before it first suspends. The caller inherits the suite active at that point, including changes made while evaluating the operand of await. For successive statements after await in an async helper, the scan resumes collection after the file's synchronous code. Resumed helpers retain their argument bindings and share Jasmine's current suite in microtask order. An unconditional return or a known rejected await ends the normal path. Awaiting a built-in promise with an empty executor suspends the helper indefinitely, including its cleanup. A return from a helper's try or catch still runs its finally block. If a call in the try can throw and the catch can recover, the scan keeps the specs that follow. Calling a local async function returns a promise. Its rejection cannot enter a synchronous catch around the call. Evaluating an argument can still throw before the function starts. The scan follows known local calls in helper arguments from left to right. A spec they register counts toward the enclosing suite, and a thrown argument prevents the remaining arguments from running. Calling a generator or async generator binds its parameters immediately. A default can register a spec or throw into the caller's catch before the caller receives the iterator. A default can read an earlier parameter. Reading its own parameter or a later one before initialization stops the call at that expression. Creating a closure delays its reads until the closure runs. For an ordinary local helper, the scan checks defaults and then follows the body with the arguments from that call. A default that registers a spec counts toward the enclosing suite. Awaiting a primitive literal such as 0 or null always fulfills. If the rest of the try also succeeds, the scan omits specs declared in its catch. jasmine.DEFAULT_TIMEOUT_INTERVAL set in a helper or spec file is not read. A beforeEach in a helper file runs around every spec, but is not counted in hooks.

Cypress ​

Cypress 10.0 and newer.

Where test comes from ​

FormExample
GlobalsMocha's BDD globals, describe, context, it, specify, their x forms and the hooks, which Cypress sets in every spec
Kept in a variableconst later = it.skip: only what both branches of a choice share applies, also of one written in place, as (process.env.CI ? it.skip : it)(...)
Local helpers fileimport { it } from './helpers' or require('./helpers'), followed through local imports, and helper functions that declare tests, read at each call

Calls ​

Cypress reads tests and describes as Mocha does, with these differences:

CallRead as
it(title, config, fn), describe(title, config, fn)A test or describe with Cypress's test config, before its function. it(title, config) without a function is a test that runs and fails, as Cypress then gives Mocha the config as its function.
retries in a test configretries; for { runMode, openMode }, runMode, which cypress run uses. A describe's passes to its tests. null sets none.
browser in a test configThe test, or a describe's tests, skipped under a condition, browser: '!firefox' as written: Cypress runs them only in the browsers it names.
tags in a test configtags, a string or a list, as @cypress/grep reads them. A describe's pass to its tests.
env in a test configFrom Cypress 16, a removed-api error: Cypress 16 fails each test it applies to when the test runs.
this.retries() in a describe, .retries() after it() or describe()A describe-throws or invalid-chain error: Cypress throws while it loads the spec. In a test or hook, this.retries() fails only that test or hook, when it runs, and is not reported.
this.timeout(), it(...).timeout()Not read: Cypress has no test timeout, only command timeouts.

A call Cypress refuses, as it.concurrent() or a describe without a function, fails its spec, and every test in the file is notLoaded; the other specs run.

WebdriverIO ​

WebdriverIO 7.0 and newer, with Mocha or Jasmine. The config's framework decides which, Mocha by default; Cucumber's feature files are not read.

Where test comes from ​

FormExample
GlobalsWith Mocha, its BDD globals, or with mochaOpts.ui: 'tdd' suite and test; with Jasmine, describe, it and their x and f forms. WebdriverIO sets them in every spec file.
Kept in a variableconst later = it.skip: only what both branches of a choice share applies, also of one written in place, as (process.env.CI ? it.skip : it)(...)
Local helpers fileimport { it } from './helpers' or require('./helpers'), followed through local imports, and helper functions that declare tests, read at each call

Calls ​

Tests and describes are read as in Mocha or Jasmine, with these differences:

CallRead as
it(title, fn, n) with Mocharetries: WebdriverIO runs the function up to n more times when it fails. It does so inside each of Mocha's attempts, so with this.retries() as well, the record shows WebdriverIO's count; 0 leaves Mocha's. it.only and it.skip drop the count, as they pass Mocha only the title and function.
it(title, fn, ms, n) with Jasminetimeout, as in Jasmine, and retries, WebdriverIO's.
A Mocha or Jasmine version gateRead with the version WebdriverIO depends on: Mocha 12 and Jasmine 6 from WebdriverIO 10, Mocha 10.8 and Jasmine 5 before. So describe(...).timeout(ms) reaches its tests from WebdriverIO 10, and Jasmine 7's notApplicable() is not read.
A call the runner refusesThe same errors as in Mocha or Jasmine, with what WebdriverIO does then. With Mocha, the file stops loading at the call: the tests declared above it run, those below are notLoaded, and the spec files grouped after it in the same worker don't run. With Jasmine, a call refused at the top level fails the whole worker: the file's tests are notLoaded, and the files grouped with it don't run either. Other workers run.

node:test ​

Node.js 22.0 and newer, the version the project pins; see framework version.

Where test comes from ​

FormExample
Default importimport test from 'node:test', whose test also carries describe, it, suite and the hooks
Named import, also renamedimport { describe, it, suite, test } from 'node:test'
require()const test = require('node:test'), whole, destructured or in place, as require('node:test').it(...)
Kept in a variableconst later = test.skip: only what both branches of a choice share applies, also of one written in place, as (process.env.CI ? test.skip : test)(...)
Local helpers fileimport { it } from './helpers' or require('./helpers'), followed through local imports, and helper functions that declare tests, read at each call

node:test sets no globals: it() without an import is not a test.

Calls ​

CallRead as
test(name, options, fn), it, and describe or suiteA test or describe. Each part may be left out: without a name, the test is named after its function, or <anonymous>; an object first is the options. A test without a function runs and passes.
.skip, .todo, .only, from Node.js 24.14 .expectFailureA skipped or todo test or describe, isOnly, or expectedToFail. Any other member, as test.concurrent, is an invalid-chain error: At file level Node.js fails the file; inside a describe it stops that callback, while earlier tests and tests outside it still run.
{ skip }, { todo }A skipped or todo test or describe, with a string as its reason; only false and undefined set nothing, as in Node.js, where even '' and 0 skip. A value the scan can't work out is a condition. skip wins over todo, and both over expectFailure.
{ only }isOnly. Under node --test, Node.js applies it only with --test-only.
{ timeout }, { concurrency }timeout, and isParallel when concurrency is true or an integer above 1, inherited through describes and parent tests. null and undefined keep the inherited mode. A known concurrency value outside the boolean or 1 to 4294967295 integer range is an unresolved-option error when the declaration loads.
{ expectFailure }From Node.js 24.14 and 25.5, expectedToFail; from 24.15 and 25.8 a string is its label, in reason.
{ tags }From Node.js 24.19 and 26.2, tags.
t.skip(reason), t.todo(reason)On the test's context, its function's first parameter, including callbacks passed by name: the test skipped or todo. The body still runs, and so do its subtests.
t.test(...), or test() or it() called in a test's bodyA subtest: a test record with the titles of the tests around it in suitePath and the test that runs it in parentTestId. A subtest of a test skipped where it is declared is skipped too, as its body never runs.
before, after, beforeEach, afterEachHooks, counted as beforeAll, afterAll, beforeEach and afterEach.

Not read: t.todo() before a t.test() call, which makes the subtest todo too; t.skip() in a beforeEach hook, which skips each test; t.test() in a helper function the test passes its context to; and a describe inside a test body, which runs as a nested describe and gets a nested-test warning. A glob in a script is read as written, though sh, which npm runs scripts with, reads an unquoted ** as *; quote it, as Node.js expands it then.

Bun ​

Bun 1.2.23 and newer, which runs tests the way 1.3 and 1.4 do; see framework version.

Where test comes from ​

FormExample
Globalstest, it, describe, xtest, xit, xdescribe and the hooks, which bun test sets in its test files
Importsimport { describe, test } from 'bun:test', a namespace or default import, or require('bun:test'); imports from @jest/globals and vitest too, which Bun rewrites to bun:test
Kept in a variableconst later = test.skip: only what both branches of a choice share applies, also of one written in place, as (process.env.CI ? test.skip : test)(...)
Local helpers fileimport { it } from './helpers' or require('./helpers'), followed through local imports, and helper functions that declare tests, read at each call

Calls ​

CallRead as
test(title, fn, options), test(title, options, fn)A test. Options are a number, the timeout, or { timeout, retry, repeats }. A retry above 0 with any repeats, 0 too, is an invalid-chain error from Bun 1.3, which refuses them together.
.skip, .todo, .failing, .only, .concurrent, .serialA skipped, todo or expectedToFail test, isOnly, or isParallel. A chain may hold them in any order, but only one of skip, todo and failing, one only, and one of concurrent and serial; another is an invalid-chain error: Bun fails the file. skip wins over todo, and todo over failing.
.if(condition), .skipIf, .todoIf, .failingIf, .concurrentIf, .serialIfA state under a condition: if skips when its condition is false, the others set theirs when it is true. A condition that holds counts as its mode in the chain, so test.todoIf(true).failing is an invalid-chain error as test.todo.failing is; one the scan can't work out counts as not holding. A describe can't be failing.
.each(table)One record with caseCount, as for Jest; with expandCases, each case titled as Bun titles it: %s a string, %d and %f a number, %i an integer, %j and %o JSON, %# the index, %% a %, and $key a value of an object case, quoted before Bun 1.3. A value of another type leaves its percent placeholder as written. Percent placeholders stay literal once the positional arguments run out. %p, and $key of an object, keep the cases as one record. A table that isn't an array is an invalid-chain error: Bun fails the file.
test(title) without a functionBun fails the file with test-without-body. Skipped and todo tests and suites can omit the callback or pass a null callback. With a function as its only argument, Bun collects an unnamed test or suite.
beforeAll, afterAll, beforeEach, afterEachHooks.

Bun reads named placeholders from the first argument when it is an object or array. In an object row, $legs.0.qty reads the first leg’s quantity, and $venue.length reads a string’s length. In a table passing an array as its first argument, $length reads that array’s length. A digit can start a path segment after a dot. Bun keeps the text of a missing, null or undefined field and consumes the next separator, so $missing, open becomes $missing open. A dollar or percent sign inserted from the row stays literal. If the row explicitly sets desk to null or undefined, $desk.name throws during collection. At the top level the file fails. Inside a describe its suite fails.

A refusal inside a describe fails that describe, whose tests are notLoaded with stateSource: "suite"; tests outside it still run.

A .only makes Bun run only the focused tests of its file, and from 1.3 with --only, none of the files without one; from 1.3, with CI=true, as in GitHub Actions, it fails its file instead. The other tests of the file are listed as written, with isOnly on the focused ones.

In every runner ​

  • Tests in loops, conditions and plain functions are listed with isInLoop, isInCondition and isInFunction.
  • A test or describe declared inside a test body or a hook is not listed, with a nested-test warning, except a node:test subtest, which is listed with parentTestId.
  • TypeScript wrappers such as test!.skip(...) and (test as any).only(...) are read through.
  • A test function kept in a variable may be chosen with ?:, &&, || or ??, as in const onCi = process.env.CI && test.skip || test: only what every choice shares applies. Choices between Jest .each factories keep the table, as in (process.env.CI ? it.skip.each : it.each)(symbols)('quotes %s', () => {}). In Vitest, an .each or .for factory must be called on its test or describe function. Taking the factory out through a variable, a conditional, a logical choice or a comma expression loses that receiver and fails the file.
  • .js, .mjs and .cjs files may contain JSX.

For Mocha, Cypress and WebdriverIO on Mocha, isOnly follows Mocha's filtering: a suite's own focused tests exclude every child suite; otherwise focus inside a suite replaces its outer focus. Standalone Mocha shares a root suite across files.

Vitest modifiers go before a called .each or .for; test.each(table).skip(...) is an invalid-chain error.

Documentation for test-inventory 0.12.2. Released under the MIT License.