only
Creates a new test scope that’s run exclusively.
static
only(name: string, f: (scope: TestScope) => void): void
Notes
- Multiple exclusive test scopes can be added at the same time. Only the tests in those scopes will run, and none of the others.
- The function argument is still invoked for other
describe(...)
calls, even if tests won’t be run.
Parameters
- name — The name of the test scope
- f — A function that’s run immediately, which should add tests using the test() function. The new TestScope instance is passed as the only argument.
Example
// only tests in the first scope are run
describe.only("Run these only", () => {
test("Foo", () => {});
// ...
})
describe("Not run", () => {
test("Bar", () => {});
// ...
})
Related
- function describe(name, f)Creates a new test scope.