describe
defines a test suite. It supports chainable modifiers and parameterized methods for flexible and organized test grouping.
(name: string, fn: () => void | Promise<void>) => void
Defines a test suite that can contain multiple test cases or nested describe blocks.
Only run the describe block(s) marked with only
.
Skip the describe block(s) marked with skip
.
It should be noted that the skip tag is only used to skip test cases, and the code inside the describe block will still be executed. This is because Rstest needs to collect information about test cases to ensure that all features work properly, even if they are marked as skipped. For example, in snapshot tests, it determines whether a snapshot is outdated or marked as skipped.
Mark a describe block as todo.
describe.each(cases: ReadonlyArray<T>)(name: string, fn: (param: T) => void | Promise<void>) => void
Creates a describe block for each item in the provided array.
describe.for(cases: ReadonlyArray<T>)(name: string, fn: (param: T) => void | Promise<void>) => void
Alternative to describe.each
for more flexible parameter types.
Run the describe block only if the condition is true.
Skip the describe block if the condition is true.
Run the tests in the describe block concurrently.
Run the tests in the describe block sequentially (default behavior).
describe
supports chainable modifiers, so you can use them together. For example:
describe.only.runIf(condition)
(or describe.runIf(condition).only
) will only run the describe block if the condition is true.describe.skipIf(condition).concurrent
(or describe.concurrent.skipIf(condition)
) will skip the describe block if the condition is true, otherwise run the tests concurrently.describe.runIf(condition).concurrent
(or describe.concurrent.runIf(condition)
) will only run the describe block concurrently if the condition is true.describe.only.concurrent
(or describe.concurrent.only
) will only run the describe block concurrently.