How to use multiple workers for running multiple tests?

I have a project that has 6 tests that need to be run, and I’d like to run them in parallel (They are on the same spec file).

I tried setting “parallelism: 6” on my config.yml file, but it just had 6 workers that each ran all 6 tests. How can I set it up so each worker just does one of the 6 tests?

Can you post the jobs: section of your circleci.yml file as that is the part that is not being processed as you expect.

Thanks - I’ve posted the jobs section below.

When I run the command “npx playwright test tests/check-in.spec.ts --project=chromium” on my local, it uses 6 workers (I have “fullyParallel: true” in my playwright.config.ts file)

jobs:
  check-in:
    machine:
      image: ubuntu-2004:2022.10.1
    parallelism: 6
    steps:
      - checkout
      - run: npm ci
      - run: npx playwright install --with-deps
      - run:
          name: Run Tests
          no_output_timeout: 120m
          command: npx playwright test tests/check-in.spec.ts --project=chromium
      - store_artifacts:
          path: playwright-report/
          destination: playwright-report

I do not know much about playwright, but I think the issue is that you currently have circleci creating 6 environments in which playwright goes and executes a complete set of all the tests as it is not aware of all the independent environments.

The playwright docs indicate that it supports a feature called sharding that would allow tests to be spread across all the independent environments here (“Sharding in CircleCI”)

   https://playwright.dev/docs/ci

If you look into the Sharding feature you may end up with a solution.

2 Likes

Thanks!

I actually found for my case, I just needed to update the playwright.config.ts file. This variable was configured differently for a CI tool than on my local, which is why it worked only on my local.

I changed “workers: process.env.CI ? 1 : undefined” to “workers: process.env.CI ? 6 : undefined”