1

I've an e2e test that uses an authenticated user, and uses a button to start a process:

load page
-> click start button
   -> load new page
   -> check process ends
   -> click close (process page)
-> click stop button

(and if the process is already running, the page offers reconnect & stop buttons instead)

This is fine, and I have a test that happily hits the stop button if the process is marked as running, and continues from there

The flaw with this technique is when testing across three browsers [aka projects] - when a 2nd worker starts up, to test the page in a different browser, it spots the process is running [from worker 1]... and shuts the process down - which breaks worker 1.

Running this particular test with --repeat-each=100 --workers=1, I get three failures across two browsers (which may be to do with the process-page loading - not sure yet)... so the use of parallel workers is essentially killing that specific test.

Obviously I don't want to run everything with just one worker... just those tests where an authenticated user does stuff in the UI.

Is there a way to set specific tests to run on a single worker?

(I can cope if it's at test, test.describe, or file level... that's just organisation & typing)

CodeGorilla
  • 811
  • 1
  • 6
  • 21

1 Answers1

0

Does it have to be the same user? You could have them each authenticate with different users (or a user per worker).

If it does, I don’t believe there’s a way to specify workers at that level from what I can find, but you could use serial mode so that only one test within that file/describe runs at a time.

David R
  • 493
  • 2
  • 8
  • Actually, that probably wouldn’t help if you’re running multiple projects Perhaps those tests should be their own project? Then turn [fullyParallel off for that project](https://playwright.dev/docs/api/class-testproject#test-project-fully-parallel) so tests within a file don’t run in parallel, and then in the file do a describe per browser (maybe with a loop), and specify the [browserName to test.use](https://playwright.dev/docs/api/class-testoptions#test-options-browser-name). If that actually ends up being the solution you need, I’ll edit my answer accordingly. – David R Mar 09 '23 at 05:10
  • It does, really..... I can get _a_ test user into the company authentication system - but trying to get multiple is going to raise questions. and I don't really want to "mock" that part, because that's going to create more mocked users in the system [though I could, if it was my only option] – CodeGorilla Mar 09 '23 at 09:28
  • No worries, makes sense. Does the approach I mentioned in my comment work for you then? Or the (probably less recommended) one I gave in the second part of my answer? Both of those would cause one test from that set of tests to run at a time, which I believe is what you needed? – David R Mar 09 '23 at 09:43
  • I'll need to investigate the "make another project" thing - and see how that sits with the current "each browser is a project" config that came out-the-box..... however I _think_ it makes sense.... and I've just discovered the "make a browser in a test" think :) – CodeGorilla Mar 09 '23 at 09:51
  • I couldn't figure an extra project... in the end I just dropped the whole test suite down to a single worker... "serial mode" wasn't applicable – CodeGorilla Mar 10 '23 at 07:39