Rayrun
← Back to Discord Forum

Global Playwright e2e Config in NX Monorepo

man_bear_pig_79posted in #help-playwright
Open in Discord
man_bear_pig_79
man_bear_pig_79

Hello guys is this kind of setup possible in a mono repo. We have more than 10 applications in our NX workspace so this also means 10 different config files, which can easily go out of sync with each other especially when there are multiple teams working in a single mono repo... it would be good if there's only 1 source of truth when it comes to how PW is configured globally.

This thread is trying to answer question "Is it possible to have a single, global Playwright end-to-end testing configuration in an NX Monorepo with multiple applications?"

0 replies

Answer

Sure, you can set up a global Playwright end-to-end testing configuration in an NX Monorepo with multiple applications. Let's start by creating a playwright.config.ts file at the root of your NX Monorepo. This file will hold the configuration options for all your applications' end-to-end tests. Here's how you can define a timeout of 60000 milliseconds (60 seconds) for all tests:

import { defineConfig } from '@playwright/test';

export default defineConfig({
  timeout: 60000,
});

But what if you want to customize settings for individual projects within your NX Monorepo? No problem. Let's say you have two applications: "staging" and "production". You want to run tests against both environments but with different retry settings. Here's how you can do it:

import { defineConfig } from '@playwright/test';

export default defineConfig({
  timeout: 60000,
  projects: [
    {
      name: 'staging',
      use: {
        baseURL: 'https://staging.ray.run',
      },
      retries: 2,
    },
    {
      name: 'production',
      use: {
        baseURL: 'https://production.ray.run',
      },
      retries: 0,
    },
  ],
});

In this example, the "staging" project runs tests against the staging environment with 2 retries, while the "production" project runs tests against the production environment with 0 retries. This way, you can easily run a subset of tests against specific environments or customize settings as needed.

Remember, this is a basic setup. Depending on your specific requirements, you might need to refer to the Playwright documentation or consult with experienced developers. Happy testing!

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