Rayrun
← Back to Discord Forum

Serialize test on multiple files

hello!

Consider this scenario:

  • 2 test file, in the first one, we test the admin view, and in the second one a second type of user can view what admin added.
  • In the first file i make a creation
  • In the second file i make a test to check if the creation was made successfully.

Is there a way to wait for the test in the first file to end before starting the test in the second file, knowing that i cant put them together in the same describe?

This thread is trying to answer question "Is there a way to wait for the test in the first file to end before starting the test in the second file without combining them into the same describe?"

4 replies

Serialize test on multiple files

Can't you combine them in just 1 file then run them in serial mode?!

I don't know of a way to serialize tests that aren't in the same file, and it's generally not a good practice to have tests dependent on each other.

Could you use mocking for these tests? For example, you could make it so that the admin user isn't actually modifying the state, and the other user opens the page that is mocked to look like what the admin created. If you did this, you'd want a unit test to make sure that the admin can make the change as expected.

if you can't put them together in the same describe, you can join it in one test file and just add 2 test.describe one for creation and the second one is a check for creation.

so you have this in one test file

`test.describe.configure({ mode: 'serial' });

test.describe("Creation", () => { }

test.describe("Check for Creation", () => { }`

i haven't tested this, but you should try it if this fix your problem

TwitterGitHubLinkedIn
AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].