@alphabin/trx
Version:
TRX reporter for Playwright tests with Azure Blob Storage upload support
126 lines (114 loc) • 3.77 kB
JavaScript
// @ts-check
/**
* Complete example configuration showcasing the HTML report upload feature
*/
/** @type {import('@playwright/test').PlaywrightTestConfig} */
const config = {
testDir: './tests',
timeout: 60 * 1000,
fullyParallel: true,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 2 : undefined,
// Configure reporters - HTML reporter is required for upload feature
reporter: [
['html', {
outputFolder: 'playwright-report',
open: 'never'
}],
['json', { outputFile: 'test-results/report.json' }],
['@alphabin/trx', {
// Required configuration
serverUrl: process.env.TESTREPORTX_SERVER_URL || 'https://api.testreportx.com',
apiKey: process.env.TESTREPORTX_API_KEY,
// Upload Configuration
// disableUpload: false, // Default: false (uploads enabled)
// disableUpload: true, // Set to true to disable HTML report uploads
// Optional: Metadata collection (all default to true)
collectGitMetadata: true,
collectCiMetadata: true,
collectSystemMetadata: true,
// Optional: Custom metadata and tags
customMetadata: {
'test.environment': process.env.TEST_ENV || 'staging',
'test.suite': 'e2e-regression',
'ci.buildNumber': process.env.BUILD_NUMBER
},
tags: [
'automated',
process.env.TEST_ENV || 'staging',
process.env.BRANCH_NAME || 'main'
],
// Optional: API configuration
timeout: 45000,
retries: 3,
debug: process.env.DEBUG_TESTREPORTX === 'true'
}]
],
// Configure projects with trace collection (will be uploaded automatically)
projects: [
{
name: 'chromium',
use: {
browserName: 'chromium',
viewport: { width: 1280, height: 720 },
headless: true,
// Enable traces for failed tests (will be uploaded with HTML reports)
trace: 'retain-on-failure',
screenshot: 'only-on-failure',
video: 'retain-on-failure'
},
},
{
name: 'firefox',
use: {
browserName: 'firefox',
viewport: { width: 1280, height: 720 },
headless: true,
trace: 'retain-on-failure',
screenshot: 'only-on-failure'
},
}
],
// Output directory configuration
outputDir: 'test-results',
// Web server (if needed)
webServer: {
command: 'npm run start',
url: 'http://localhost:3000',
reuseExistingServer: !process.env.CI,
timeout: 120 * 1000
},
};
module.exports = config;
/*
* UPLOAD FEATURE NOTES:
*
* 1. HTML Reporter Required:
* - The HTML reporter must be configured for uploads to work
* - If not configured, you'll get a warning
* - Set disableUpload: true to disable the feature
*
* 2. What Gets Uploaded:
* - All files from the HTML report directory (playwright-report by default)
* - Traces, screenshots, videos, and other test artifacts
* - Directory structure is preserved on Azure
*
* 3. Access Your Reports:
* - After upload, you'll get a direct URL to view the HTML report
* - Format: https://testreportx.blob.core.windows.net/.../index.html
* - Reports are publicly accessible via the URL
*
* 4. Configuration Options:
* - disableUpload: true/false - Enable/disable uploads
* - All other existing options remain the same
*
* 5. Error Handling:
* - Upload failures don't affect main test reporting
* - Automatic retry (3 attempts) for failed uploads
* - Clear error messages and suggestions
*
* 6. Environment Variables:
* - TESTREPORTX_SERVER_URL: Your TestReportX server URL
* - TESTREPORTX_API_KEY: Your API key for authentication
* - DEBUG_TESTREPORTX: Set to 'true' for debug logging
*/