Describe
describe defines a test suite. It supports chainable modifiers and parameterized methods for flexible and organized test grouping.
describe
- Type:
(name: string, fn: () => void | Promise<void>) => void
Defines a test suite that can contain multiple test cases or nested describe blocks.
describe.only
Only run the describe block(s) marked with only.
describe.skip
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.
describe.todo
Mark a describe block as todo.
describe.each
- Type:
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
- Type:
describe.for(cases: ReadonlyArray<T>)(name: string, fn: (param: T) => void | Promise<void>) => void
Alternative to describe.each for more flexible parameter types.
describe.runIf
Run the describe block only if the condition is true.
describe.skipIf
Skip the describe block if the condition is true.
describe.concurrent
Run the tests in the describe block concurrently.
describe.sequential
Run the tests in the describe block sequentially (default behavior).
Chainable modifiers
describe supports chainable modifiers, so you can use them together. For example:
describe.only.runIf(condition)(ordescribe.runIf(condition).only) will only run the describe block if the condition is true.describe.skipIf(condition).concurrent(ordescribe.concurrent.skipIf(condition)) will skip the describe block if the condition is true, otherwise run the tests concurrently.describe.runIf(condition).concurrent(ordescribe.concurrent.runIf(condition)) will only run the describe block concurrently if the condition is true.describe.only.concurrent(ordescribe.concurrent.only) will only run the describe block concurrently.- ......