跳到正文
本页尚未翻译成中文,以下为英文原文。 查看英文版

TestRun ​

Added in: v1.62

Controls which tests will run and their expected status, and provides information about suite execution modes. A TestRun is available during reporter.preprocess(). Setup and teardown projects cannot be changed.

Methods ​

testRun.exclude() ​

Added in: v1.62

Excludes a test or suite from the run. Excluded tests do not appear in the report and their bodies are not executed.

Arguments

  • test TestCase | Suite

    Test or suite to exclude. The root suite cannot be excluded.

testRun.fail() ​

Added in: v1.62

Marks a test or every test in a suite as "should fail". Playwright runs the tests and ensures they are actually failing, useful for documenting broken functionality until it is fixed.

Arguments

  • test TestCase | Suite

    Test or suite to mark as expected-to-fail.

  • reason string (optional)

    Optional explanation surfaced as the annotation description.

testRun.fixme() ​

Added in: v1.62

Marks a test or every test in a suite as fixme. The test bodies are not executed and the tests are reported as skipped, with the intention to fix them.

Arguments

  • test TestCase | Suite

    Test or suite to mark as fixme.

  • reason string (optional)

    Optional explanation surfaced as the annotation description.

testRun.mode() ​

Added in: v1.65

Returns the execution mode configured for a suite with test.describe.configure(), test.describe.serial() or test.describe.parallel(). If the suite does not configure a mode, it inherits its parent's mode. Project suites use "parallel" when testProject.fullyParallel is enabled, and "default" otherwise. The root suite uses "default".

An explicit "default" suite does not inherit "parallel" from its parent: its tests run in order in the same worker. The mode alone does not describe complete test groups, which also depend on worker fixtures and hooks.

This method can only be called during reporter.preprocess(), and can also inspect setup and teardown projects.

Arguments

  • suite Suite

    Suite to inspect.

Returns

  • "serial" | "parallel" | "default"

testRun.skip() ​

Added in: v1.62

Skips a test or every test in a suite. The test bodies are not executed and the tests are reported as skipped.

Arguments

  • test TestCase | Suite

    Test or suite to skip.

  • reason string (optional)

    Optional explanation surfaced as the annotation description.

testRun.skipSharding() ​

Added in: v1.62

Disables Playwright's built-in shard filter for this run, leaving sharding to the reporter. Reporters typically implement their own sharding by calling testRun.exclude() on out-of-shard tests.

基于 Apache 2.0 许可证发布。