To display log levels and account information in your Playwright test reports, you'll need to use the HTML reporter and add custom metadata to your tests.
First, specify the HTML reporter in your playwright.config.ts
file. This reporter generates an HTML report that includes logs with their respective log levels.
import { defineConfig } from '@playwright/test';
export default defineConfig({
reporter: [['html', { outputFolder: 'my-report' }]],
});
In this configuration, we're using the HTML reporter and specifying an output folder (my-report
in this example) where the report will be generated.
Next, add custom metadata to your tests using the test.meta
function. This metadata can include additional information such as the account used for logging in.
import { test } from '@playwright/test';
test('Login Test', async ({ page }) => {
// Login logic here
// Add metadata for account information
test.meta({ account: '[email protected]' });
// Rest of your test code
});
In this example, we added a meta
call within our login test and specified an account
key with its corresponding value ([email protected]
). This metadata will be associated with this specific test case.
When you run your tests with one of Playwright's built-in reporters (such as HTML or JSON), the metadata will be included in the report. You can customize the reporter configuration to display this information in a way that suits your needs.
Remember, while Playwright provides built-in reporters, you can also create custom reporters for more specific reporting functionality. For more details, refer to Playwright's official documentation and the Mastering Playwright Test Automation: Your Comprehensive Cheat Sheet blog post.
If you still have questions, please ask a question and I will try to answer it.
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].