playwright-community / jest-playwright

Running tests using Jest & Playwright
MIT License
532 stars 75 forks source link

[Question] Access to the displayName: 'edge' from the test file #781

Closed emakhachek closed 3 years ago

emakhachek commented 3 years ago

Hello! I use JUnit for reporting. It produces test results which are shown on Azure UI. I added browserName into the describe in order to understand which browser was running. If tests are running in Edge, it is displayed as Chromium in the test results. Could you please help me: is it possible somehow insert ‘edge’ into the test suite name instead of ‘chromium’?

let runModeBrowser = [];

if (!process.env.BROWSER) {
    runModeBrowser = ['chromium'];
    process.env.BROWSER = 'chromium';
} else {
    process.env.BROWSER.split(',').map(browser => {
        switch (browser) {
            case 'firefox':
                runModeBrowser.push('firefox');
                break;
            case 'chrome' || 'chromium':
                runModeBrowser.push('chromium');
                break;
            case 'safari' || 'webkit':
                runModeBrowser.push('webkit');
                break;
            case 'edge' || 'msedge':
                runModeBrowser.push({ displayName: 'edge', name: 'chromium', launchOptions: { channel: 'msedge-dev' } });
                // https://github.com/microsoft/playwright/blob/07fb81a4efdcc4c2169a61a16b513b9d91be6c49/src/server/chromium/findChromiumChannel.ts#L38
                break;
            default:
                break;
        };
        return runModeBrowser;
    })
};

// Run in headless mode by default (if process.env.HEADLESS is not specified)
const runModeHead = !process.env.HEADLESS || process.env.HEADLESS === 'true' ? true : false;
// Bottom menu is hidden, pagination block is unreached if viewport config is enabled while running in headful mode (probably PW issue)
const runModeViewport = runModeHead ? { width: 1920, height: 1080 } : null;

module.exports = {
    exitOnPageError: false,
    launchOptions: {
        headless: runModeHead,
        slowMo: parseInt(process.env.SLOWMO) || 0
    },
    launchType: "LAUNCH",
    contextOptions: {
        viewport: runModeViewport,
        acceptDownloads: true,
        // recordVideo: {
        //     dir: './results/videos',
        //     size: customViewport,
        // }
    },
    browsers: runModeBrowser
}
describe(`${browserName.toUpperCase()}` + "_TagBasic_", () => {

  test("Tags_total_quantity_is_greater_than_50", async () => {
     ...
  });
});

image

mxschmitt commented 3 years ago

jest-playwright is in maintenance mode, we recommend switching to the official test-runner: https://playwright.dev/docs/intro

The official test-runner provides custom projects which you can name accordingly. See here: https://playwright.dev/docs/test-configuration#different-options-for-each-browser