Skip to content

[Feature]: custom reporter API for test sharding #40934

Closed

Description

🚀 Feature Request

Hi team,

We'd like to implement a shard balancing logic in Flakiness.io Playwright reporter: since we have all the history for test runs across environments, we have enough data to balance shards.

We know there's --test-list API that we can use to generate a list with tests (and that's what we use for prototyping). However, this is not an ergonomic API for our clients: it requires them to change their CI configuration.

Custom Reporter API is a better integration point: there's already a full information for the upcoming test run.

Example

It would be nice if custom reporters had an early asynchronous hook that could inspect the resolved test suite and return a custom test list before execution starts.
For example, a reporter method called in the beginning of the run would do:

interface Reporter {
  /**
   * Called before the test run starts. Allows the reporter to customize
   * the list of tests that will be executed. Returns an array of test case Ids. 
   */
  selectTests?(
    config: FullConfig,
    suite: Suite
  ): undefined | Promise<undefined | string[]>;
}

Motivation

Consider this Supabase CI: if they were to try using --test-list with Flakiness.io, they'd need to amend their workflow configuration.

Additionally, if they were passing any custom arguments like --grep to their future npx playwright test run, they'd need to mirror them to the test-list generation command.

Activity

  1. Skn0tt commented on May 26, 2026

    @Skn0tt
    Contributor

    Dmitry Baev (@baev) I think you'd also be interested in this - we're thinking of exposing it via a separate config field as opposed to extending Reporter, what do you two think?

  2. baev commented on May 27, 2026

    @baev

    Simon Knott (@Skn0tt) thanks for asking. Yes, we’re looking forward to having this feature implemented. From our POV, the fewer config changes people have to make to configure Allure, the better. So, we would prefer a reporter hook instead of a separate config field.

  3. Skn0tt commented on May 27, 2026

    @Skn0tt
    Contributor

    I feel similar, but it makes our Reporter a bit of a misnomer. Is there a convincing story for the role of Reporter that would allow it to have this method without feeling icky?

    Also, I think we'd want the selectTests result to carry some kind of a disposition; so on top of sharding it can be used to mark some tests as fixme/skipped according to a platform/feature matrix. What kinds of dispositions would you like to see in the context of your systems Dmitry Baev (@baev) Andrey Lushnikov (@aslushnikov)?

  4. baev commented on May 27, 2026

    @baev

    The test plan feature lets Allure control which tests should run without turning Allure into a test framework. Allure decides the target subset, writes that subset as a testplan.json, and the test-framework adapter, for example allure-playwright, applies the filter before selected tests execute.

    For users, the expected behavior is simple: when they choose a subset of tests, only those tests run. Tests outside the plan should not execute their body, per-test fixtures, steps, or helper code, and they should not appear as artificially skipped results. If the plan is missing, invalid, unsupported, or empty, the run falls back to normal execution.

    This supports two main flows:

    1. allure run can automatically rerun failed tests. After the first pass, Allure 3 finds failed or unsuccessful tests, creates a temporary testplan.json, sets ALLURE_TESTPLAN_PATH and ALLURE_RERUN, then launches the same command again for only that subset.

    2. When a run is triggered from Allure TestOps, the selected tests can be passed to the execution as an Allure test plan. The adapter filters the framework run automatically, so users do not need to manually translate TestOps selection into Playwright grep patterns or custom runner flags.

    We already implemented this for allure-playwright using monkey-patching. Users can try it by adding the latest allure-playwright reporter and running their normal Playwright command through allure run, for example:

    allure run --rerun 2 -- npx test

    Example plan:

    {
      "version": "1.0",
      "tests": [
        {
          "id": "123",
          "selector": "tests/login.spec.ts#auth > logs in"
        }
      ]
    }

    To filter discovered Playwright tests, the adapter needs access to enough data from each discovered test to build the same identity that Allure uses in the plan:

    • test name/title
    • full file path or project-relative test file path
    • title path / suite hierarchy
    • stable fullName or equivalent selector generated from file path plus title hierarchy
    • Playwright tags and annotations
    • Allure ID from explicit metadata or tags such as @allure.id=123 / @allure.id:123
    • framework-native selector, if Playwright exposes one that is stable enough

    Pseudo-code:

    function includedInTestPlan(plan: TestPlan, test: TestContext): boolean {
      const tagId = test.tags
        ?.map((tag) => tag.match(/^@allure\.id[:=](.+)$/)?.[1])
        .find(Boolean);
    
      const effectiveId = test.allureId ?? tagId;
    
      return plan.tests.some((entry) => {
        const idMatches =
          effectiveId !== undefined &&
          entry.id !== undefined &&
          String(entry.id) === effectiveId;
    
        const selectorMatches =
          entry.selector !== undefined &&
          (entry.selector === test.fullName ||
           entry.selector === test.nativeSelector);
    
        return idMatches || selectorMatches;
      });
    }

    The core contract: Allure provides the selected test set; allure-playwright makes Playwright execute only that set.

  5. Skn0tt commented on May 27, 2026

    @Skn0tt
    Contributor

    We discussed it with the team, i'll add a filter to Config. It initially means one more thing to configure for the user, but that can be solved separately via merging configs / plugins.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions