DEV Community

Ivan Tanev
Ivan Tanev

Posted on

Quick Tip: Simpler sharding configuration for Playwright

Playwright’s sharding docs present the following GitHub actions configuration:

strategy:
  fail-fast: false
  matrix:
    shardIndex: [1, 2, 3, 4]
    shardTotal: [4]
[...]
steps:
- name: Run Playwright tests
  run: |
    npx playwright test \ 
      --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
Enter fullscreen mode Exit fullscreen mode

While it works, I think the following reads much better:

strategy:
  fail-fast: false
  matrix:
    shard: ["1/4", "2/4", "3/4", "4/4"]
[...]
steps:
- name: Run Playwright tests
  run: npx playwright test --shard=${{ matrix.shard }}
Enter fullscreen mode Exit fullscreen mode

You don't even need the quotes around "1/4", you could write them naked, but I prefer to be explicit in yaml:

    shard: [1/4, 2/4, 3/4, 4/4]
Enter fullscreen mode Exit fullscreen mode

What do you think?

Top comments (0)