Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/reporters/playwright.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,18 @@ const makeTestName = (test) => {
.join(' > ');
};

const getBrowser = (project) => {
const getBrowser = (project, logger) => {
const { name, use: { browserName, defaultBrowserType } = {} } = project;
const browser = (browserName ?? defaultBrowserType ?? name)?.trim().toLowerCase();

if (ReportBuilder.SupportedBrowsers.includes(browser)) {
return browser;
}

if (browser) {
logger.warning(`Unsupported browser '${browser}', omitting from test report detail`);
}

return null;
};

Expand Down Expand Up @@ -106,7 +110,7 @@ export default class Reporter {
detail.incrementRetries();
}

const browser = getBrowser(project);
const browser = getBrowser(project, this.#logger);

if (browser) {
detail.setBrowser(browser);
Expand Down
30 changes: 30 additions & 0 deletions src/reporters/webdriverio.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,26 @@ class WebdriverIO extends WDIOReporter {
return platformName ? platformName.toLowerCase().trim() : null;
}

#getBrowserName() {
const capabilities = this.runnerStat?.capabilities;

if (!capabilities) {
return null;
}

const browser = capabilities.browserName?.toLowerCase().trim();

if (browser && ReportBuilder.SupportedBrowsers.includes(browser)) {
return browser;
}

if (browser) {
this.#logger.warning(`Unsupported browser '${browser}', omitting from test report detail`);
}

return null;
}

#makeTestName(fullTitle) {
const platform = this.#getPlatformName();
const name = fullTitle
Expand All @@ -84,12 +104,17 @@ class WebdriverIO extends WDIOReporter {

#openDetail(suite, test) {
const id = makeDetailId(suite.file, test.fullTitle);
const browser = this.#getBrowserName();
const detail = this.#report
.getDetail(id)
.setName(this.#makeTestName(test.fullTitle))
.setLocationFile(suite.file)
.setStarted(getNowISOString());

if (browser) {
detail.setBrowser(browser);
}

if (test.timeout) {
detail.setTimeout(test.timeout);
}
Expand Down Expand Up @@ -159,6 +184,7 @@ class WebdriverIO extends WDIOReporter {
);

if (failedBeforeHooks.length !== 0) {
const browser = this.#getBrowserName();
const tests = suite.tests?.length ? suite.tests : failedBeforeHooks
.filter(hook => hook.currentTest)
.map(hook => ({
Expand All @@ -176,6 +202,10 @@ class WebdriverIO extends WDIOReporter {
.setStarted(getNowISOString())
.addDuration(0)
.setFailed();

if (browser) {
detail.setBrowser(browser);
}
}
}
}
Expand Down
21 changes: 21 additions & 0 deletions test/integration/data/validation/test-report-webdriverio.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,126 +13,147 @@ export const testReportLatestPartial = {
},
details: [{
name: `[${platform}] > taxonomy overrides > passed`,
browser: 'chrome',
status: 'passed',
location: { file: 'test/integration/data/tests/webdriverio/taxonomy-overrides.test.js' },
taxonomy: { tool: 'Test Reporting', type: 'integration' },
retries: 0
}, {
name: `[${platform}] > taxonomy overrides > skipped`,
browser: 'chrome',
status: 'skipped',
location: { file: 'test/integration/data/tests/webdriverio/taxonomy-overrides.test.js' },
taxonomy: { tool: 'Test Reporting', type: 'integration' },
retries: 0
}, {
name: `[${platform}] > taxonomy overrides > flaky`,
browser: 'chrome',
status: 'passed',
location: { file: 'test/integration/data/tests/webdriverio/taxonomy-overrides.test.js' },
taxonomy: { tool: 'Test Reporting', type: 'integration' },
retries: 2
}, {
name: `[${platform}] > taxonomy overrides > failed`,
browser: 'chrome',
status: 'failed',
location: { file: 'test/integration/data/tests/webdriverio/taxonomy-overrides.test.js' },
taxonomy: { tool: 'Test Reporting', type: 'integration' },
retries: 3
}, {
name: `[${platform}] > statuses > passed`,
browser: 'chrome',
status: 'passed',
location: { file: 'test/integration/data/tests/webdriverio/statuses.test.js' },
taxonomy: { tool: 'WebdriverIO 1 Test Reporting', type: 'ui' },
retries: 0
}, {
name: `[${platform}] > statuses > skipped`,
browser: 'chrome',
status: 'skipped',
location: { file: 'test/integration/data/tests/webdriverio/statuses.test.js' },
taxonomy: { tool: 'WebdriverIO 1 Test Reporting', type: 'ui' },
retries: 0
}, {
name: `[${platform}] > statuses > flaky`,
browser: 'chrome',
status: 'passed',
location: { file: 'test/integration/data/tests/webdriverio/statuses.test.js' },
taxonomy: { tool: 'WebdriverIO 1 Test Reporting', type: 'ui' },
retries: 2
}, {
name: `[${platform}] > statuses > failed`,
browser: 'chrome',
status: 'failed',
location: { file: 'test/integration/data/tests/webdriverio/statuses.test.js' },
taxonomy: { tool: 'WebdriverIO 1 Test Reporting', type: 'ui' },
retries: 3
}, {
name: `[${platform}] > special characters > special/characters "(\\n\\r\\t\\b\\f)"`,
browser: 'chrome',
status: 'passed',
location: { file: 'test/integration/data/tests/webdriverio/special-characters.test.js' },
taxonomy: { tool: 'Test Reporting', type: 'integration' },
retries: 0
}, {
name: `[${platform}] > hook failures > before all failure > test with before all failure`,
browser: 'chrome',
status: 'failed',
location: { file: 'test/integration/data/tests/webdriverio/hook-failures.test.js' },
taxonomy: { tool: 'WebdriverIO Hook Failures Test Reporting', type: 'ui' },
retries: 0
}, {
name: `[${platform}] > hook failures > before each failure > test with before each failure`,
browser: 'chrome',
status: 'failed',
location: { file: 'test/integration/data/tests/webdriverio/hook-failures.test.js' },
taxonomy: { tool: 'WebdriverIO Hook Failures Test Reporting', type: 'ui' },
retries: 0
}, {
name: `[${platform}] > hook failures > after each failure > test with after each failure`,
browser: 'chrome',
status: 'passed',
location: { file: 'test/integration/data/tests/webdriverio/hook-failures.test.js' },
taxonomy: { tool: 'WebdriverIO Hook Failures Test Reporting', type: 'ui' },
retries: 0
}, {
name: `[${platform}] > hook failures > after all failure > test with after all failure`,
browser: 'chrome',
status: 'passed',
location: { file: 'test/integration/data/tests/webdriverio/hook-failures.test.js' },
taxonomy: { tool: 'WebdriverIO Hook Failures Test Reporting', type: 'ui' },
retries: 0
}, {
name: `[${platform}] > hook failures > flaky before all > test with flaky before all`,
browser: 'chrome',
status: 'failed',
location: { file: 'test/integration/data/tests/webdriverio/hook-failures.test.js' },
taxonomy: { tool: 'WebdriverIO Hook Failures Test Reporting', type: 'ui' },
retries: 0
}, {
name: `[${platform}] > hook failures > flaky before each > test with flaky before each`,
browser: 'chrome',
status: 'failed',
location: { file: 'test/integration/data/tests/webdriverio/hook-failures.test.js' },
taxonomy: { tool: 'WebdriverIO Hook Failures Test Reporting', type: 'ui' },
retries: 0
}, {
name: `[${platform}] > hook failures > flaky after each > test with flaky after each`,
browser: 'chrome',
status: 'passed',
location: { file: 'test/integration/data/tests/webdriverio/hook-failures.test.js' },
taxonomy: { tool: 'WebdriverIO Hook Failures Test Reporting', type: 'ui' },
retries: 0
}, {
name: `[${platform}] > hook failures > flaky after all > test with flaky after all`,
browser: 'chrome',
status: 'passed',
location: { file: 'test/integration/data/tests/webdriverio/hook-failures.test.js' },
taxonomy: { tool: 'WebdriverIO Hook Failures Test Reporting', type: 'ui' },
retries: 0
}, {
name: `[${platform}] > fake timers > passed`,
browser: 'chrome',
status: 'passed',
location: { file: 'test/integration/data/tests/webdriverio/fake-timers.test.js' },
taxonomy: { tool: 'Test Reporting', type: 'integration' },
retries: 0
}, {
name: `[${platform}] > fake timers > failed`,
browser: 'chrome',
status: 'failed',
location: { file: 'test/integration/data/tests/webdriverio/fake-timers.test.js' },
taxonomy: { tool: 'Test Reporting', type: 'integration' },
retries: 3
}, {
name: `[${platform}] > custom timeout > suite level timeout`,
browser: 'chrome',
status: 'passed',
location: { file: 'test/integration/data/tests/webdriverio/custom-timeout.test.js' },
taxonomy: { tool: 'Test Reporting', type: 'integration' },
retries: 0
}, {
name: `[${platform}] > custom timeout > test level timeout`,
browser: 'chrome',
status: 'passed',
location: { file: 'test/integration/data/tests/webdriverio/custom-timeout.test.js' },
taxonomy: { tool: 'Test Reporting', type: 'integration' },
Expand Down