Skip to content

Supported syntax ​

Playwright ​

Playwright 1.42 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
Derivedbase.extend({...}), chained .extend().extend(), mergeTests(a, b)
Local fixtures fileimport { test } from '../fixtures', or a path alias, # import or workspace package, followed one file deep

Calls ​

CallRead as
test(title, body), test(title, details, body)A test. The body may be a function passed by name.
test.only, test.skip, test.fixme, test.fail with a title and bodyA test with that state.
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.describe(title, callback), with details, or anonymous test.describe(callback)A describe.
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.

Vitest ​

Vitest 3.0 and newer.

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 one file deep

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, in any order and combination.only wins over .skip, which wins over .todo.
.each(table), .for(table), also as tagged templatesOne parameterized record, with caseCount when the table is in the file.
.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 when written in the file.
// @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.

In both ​

  • 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.
  • TypeScript wrappers such as test!.skip(...) and (test as any).only(...) are read through.
  • .js, .mjs and .cjs files may contain JSX.