Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Workers config option for a project #18950

Closed
suneetfcc opened this issue Nov 21, 2022 · 16 comments
Closed

[Question] Workers config option for a project #18950

suneetfcc opened this issue Nov 21, 2022 · 16 comments
Assignees
Labels
feature-test-runner Playwright test specific issues P3-collecting-feedback

Comments

@suneetfcc
Copy link

suneetfcc commented Nov 21, 2022

My playwright config looks like

const config = {
projects: [
        {
            name: 'Project1,
            testMatch: '**/project1/**',
            workers: 1
        },
        {
            name: 'Project2',
            testMatch: '**/project2/**'
        }
    ]
}

when i run npx playwright test --project=Project1
Running 18 tests using 3 workers
the project is parallelised with 3 workers and my worker config is not honoured.

Basically i am trying to disable parallelization for one project

@viraxslot
Copy link

Hi @suneetfcc As far as I know there is no such option like workers for a project. Please see here: https://playwright.dev/docs/api/class-testproject

I think a workaround could be:

const config = {
  workers: process.env.ONE_WORKER ? 1 : 3,
  projects: [
          {
              name: 'Project1,
              testMatch: '**/project1/**',
              workers: 1
          },
          {
              name: 'Project2',
              testMatch: '**/project2/**'
          }
      ]
  }

It's like in this code snippet (please see to the very bottom of the page), but with the different environment variable.

So you can run your tests like
ONE_WORKER=1 npx playwright test --project=Project1 (will work for macOS for sure)

And with no such environment variable for other projects.
Of course environment variable can have an another name.

For Windows you need to set environment variable like set ONE_WORKER=1 before the run.
Hope it will help.

@dgozman
Copy link
Contributor

dgozman commented Nov 21, 2022

@suneetfcc There is no such feature as of today - you can only specify workers for the whole config. Let's consider this issue a feature request.

@suneetfcc
Copy link
Author

@suneetfcc There is no such feature as of today - you can only specify workers for the whole config. Let's consider this issue a feature request.

thank you so much i think this is a pretty desirable feature.

@aslushnikov aslushnikov added v1.30 and removed v1.29 labels Dec 15, 2022
@aslushnikov aslushnikov added v1.31 and removed v1.30 labels Jan 5, 2023
@dgozman dgozman added feature-test-runner Playwright test specific issues P3-collecting-feedback and removed v1.31 labels Jan 25, 2023
@kLjubomir
Copy link

I would also like to see this feature be available.

@nulladdict
Copy link

I would also love to see this feature. Here's some context for my use case.
Most of my tests can be run fully parallel, but there's a number of test suites that puts load on a shared resource.

Currently we have all this tests in a single file, effectively disabling concurrency.
Ideally, we would put them in a separate project and run those projects sequentially to mitigate side-effects on other tests.

We can also just run tests twice, but then handling results and artifacts is a bit tricky.

@HendrikJan
Copy link

I would actually like such a feature per spec-file:

test.describe.configure({ workers: 1 });

@marcusNumminen
Copy link
Contributor

I would also like to have this. In my case I work in a project were we do both api and UI tests. I have divided up this into two projects, one api-test and one ui-test project. Since I don't use the browser at all in the api-test project I can run that project with a larger amount of workers than the UI tests.

@xiaojieyang
Copy link

I would like to have this feature as well, under big project this can be quite useful.

@denkorz
Copy link

denkorz commented Sep 11, 2023

This feature looks useful, it would really help to improve management of test runs. Looking forward for new version with this feature implemented!

@inriverisac
Copy link

Looks like a great feature. I would also like this implemented!

@marcusNumminen
Copy link
Contributor

@dgozman and @aslushnikov is there any plans for adding workers option to the projects? This would have been a very nice option.

@GlacialBoy
Copy link

We'd like also to have this feature implemented so we can tune the parallization grade on different projects. Great job with Playwright!

@alexisadorn
Copy link

This would be a helpful feature for us as well, especially if it could be determined at the spec file level

@AndiBMGitHub
Copy link

Would be great to have this implemented!

@giorgoslytos
Copy link

This is a feature that would benefit us a lot!
Especially this one
test.describe.configure({ workers: 1 })

@mxschmitt
Copy link
Member

Folding into #21970

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-test-runner Playwright test specific issues P3-collecting-feedback
Projects
None yet
Development

No branches or pull requests