test defines a test case. It supports chainable modifiers and fixture extension for flexible and powerful test definitions.
Alias: it.
(name: string, fn: (testContext: TestContext) => void | Promise<void>, timeout?: number) => voidDefines a test case.
Only run certain tests in a test file.
Skips certain tests.
Marks certain tests as todo.
test.each(cases: ReadonlyArray<T>)(name: string, fn: (param: T) => void | Promise<void>, timeout?: number) => voidRuns the same test logic for each item in the provided array.
test.for(cases: ReadonlyArray<T>)(name: string, fn: (param: T, testContext: TestContext) => void | Promise<void>, timeout?: number) => voidAlternative to test.each to provide TestContext.
Marks the test as expected to fail.
Runs the test concurrently with consecutive concurrent flags.
Runs the test sequentially (default behavior).
Runs the test only if the condition is true.
Skips the test if the condition is true.
test.extend(fixtures: Fixtures)Extends the test context with custom fixtures.
test supports chainable modifiers, so you can use them together. For example:
test.only.runIf(condition) (or test.runIf(condition).only) will only run the test block if the condition is true.test.skipIf(condition).concurrent (or test.concurrent.skipIf(condition)) will skip the test block if the condition is true, otherwise run the tests concurrently.test.runIf(condition).concurrent (or test.concurrent.runIf(condition)) will only run the test block concurrently if the condition is true.test.only.concurrent (or test.concurrent.only) will only run the test block concurrently.test.for(cases).concurrent (or test.concurrent.for(cases)) will run the test block concurrently for each case in the provided array.TestContext provides some APIs, context information, and custom fixtures related to the current test.
You can also extend TestContext with custom fixtures using test.extend.