Rayrun
← Back to Discord Forum

Testing between projects with different roles

chaitanya_kposted in #help-playwright
Open in Discord
chaitanya_k

I am creating project for kind of role the user has and each have different authentication info. I am trying to test a scenario where a viewer requests to elevate permissions and the admin interacts to request and accepts/rejects request.

Is it possible to test these scenarios with different projects or does it have to be in a single project and the tests have to run in serial mode.

This thread is trying to answer question "Is it possible to test these scenarios with different projects or does it have to be in a single project and the tests have to run in serial mode?"

3 replies

So you're looking to have, as one test, two users interact with each other, where one requests the permissions and the other accepts or rejects?

chaitanya_k

Yes thats correct

chaitanya_k

Currently i was thinking of creating new project and login with one user with viewer permissions and request permissions and then login with other user and complete the request. Only problem is i have too many flows like this and there are too many login requests which might cause some issues

Answer

Configuring Projects in Playwright

Projects in Playwright are a great way to group tests with the same configuration. You can set up multiple projects in your playwright.config.ts file. Each project can have its own name and configuration options.

// playwright.config.ts
module.exports = {
  projects: [
    {
      name: 'chromium',
      use: { browserName: 'chromium' },
    },
    {
      name: 'firefox',
      use: { browserName: 'firefox' },
    },
  ],
};

This setup allows you to run tests on different browsers and devices, or even the same tests in different configurations. You can choose to run all projects or just a specific one, giving you the flexibility to focus on certain scenarios or configurations.

Serial vs Parallel Mode

Playwright supports both serial and parallel modes. In serial mode, tests are executed one after another. If one test fails, all subsequent tests are skipped. Parallel mode allows multiple tests to be executed simultaneously across separate worker processes.

// Serial mode
test.describe.serial('serial tests', () => {
  // your tests here
});

// Parallel mode
test.describe('parallel tests', () => {
  // your tests here
});

While serial mode can be useful for inter-dependent tests, it's generally recommended to make your tests isolated so they can be run independently. This provides better isolation and avoids potential dependencies between test cases.

For more tips on efficient Playwright test scripts, check out this blog post.

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].