Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

fix(tests): Report session-init crash in allure report. (#17263)

bgrozev6f4412db6e7c
diff --git a/tests/wdio.conf.ts b/tests/wdio.conf.ts
index c627638f9d..095eef8aa4 100644
--- a/tests/wdio.conf.ts
+++ b/tests/wdio.conf.ts
@@ -472,9 +472,11 @@ export const config: WebdriverIO.MultiremoteConfig = {
/**
* Gets executed after a worker process has exited.
- * If the worker crashed (e.g. session DELETE timeout), the JUnit reporter never flushes,
- * leaving a zero-byte XML file. This hook detects that and writes a failure entry so the
- * report generator has something to show.
+ * Handles two crash scenarios:
+ * 1. Session DELETE timeout: JUnit reporter never flushes, leaving a zero-byte XML.
+ * 2. Session INIT timeout: JUnit reporter writes a non-empty XML but with empty name/classname,
+ * and the allure reporter never fires (no beforeTest hook ran).
+ * In both cases, synthesise a failure entry for JUnit and allure so the crash shows up in reports.
*/
onWorkerEnd(cid, exitCode, workerSpecs) {
if (exitCode === 0) {
@@ -482,19 +484,31 @@ export const config: WebdriverIO.MultiremoteConfig = {
}
const xmlPath = path.join(TEST_RESULTS_DIR, `results-${cid}.xml`);
- try {
- if (fs.statSync(xmlPath).size > 0) {
- return;
- }
- } catch {
- // file doesn't exist yet — fall through and create it
- }
-
const specName = workerSpecs?.[0] ? path.basename(workerSpecs[0], '.spec.ts') : 'unknown';
const dirMatch = workerSpecs?.[0]?.match(/\/tests\/specs\/([^/]+)\//);
const dir = dirMatch ? dirMatch[1] : 'unknown';
const message = `Worker exited with code ${exitCode} before results were written. Test result is unknown - tests may have passed.`;
+ // Check whether the XML has real test content. The JUnit reporter writes a non-empty XML
+ // even for session-init failures, but the testcase has empty name/classname in that case.
+ // If real test results were written, the allure reporter will have already produced its
+ // own result files, so we skip both. If the XML is missing or has no named test cases,
+ // we need to synthesise both.
+ let xmlHasNamedTests = false;
+
+ try {
+ const xmlContent = fs.readFileSync(xmlPath, 'utf8');
+
+ xmlHasNamedTests = xmlContent.includes('name="') && !xmlContent.includes('name=""');
+ } catch {
+ // file doesn't exist — fall through and create it
+ }
+
+ if (xmlHasNamedTests) {
+ // Real test results were written; allure reporter handled this worker normally.
+ return;
+ }
+
const b = junitReportBuilder.newBuilder();
b.testSuite().name(specName).testCase()