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): Use worker id to create console log files.

damenchoe89776848cab
diff --git a/tests/helpers/browserLogger.ts b/tests/helpers/browserLogger.ts
index 636bc181fa..6e3fa2fdb7 100644
--- a/tests/helpers/browserLogger.ts
+++ b/tests/helpers/browserLogger.ts
@@ -9,13 +9,13 @@ export const LOG_PREFIX = '[MeetTest] ';
* Initialize logger for a driver.
*
* @param {WebdriverIO.Browser} driver - The driver.
- * @param {string} name - The name of the participant.
+ * @param {string} fileName - The name of the file.
* @param {string} folder - The folder to save the file.
* @returns {void}
*/
-export function initLogger(driver: WebdriverIO.Browser, name: string, folder: string) {
+export function initLogger(driver: WebdriverIO.Browser, fileName: string, folder: string) {
// @ts-ignore
- driver.logFile = `${folder}/${name}.log`;
+ driver.logFile = `${folder}/${fileName}.log`;
driver.sessionSubscribe({ events: [ 'log.entryAdded' ] });
driver.on('log.entryAdded', (entry: any) => {
diff --git a/tests/wdio.conf.ts b/tests/wdio.conf.ts
index a1007fa05d..c5b934cd45 100644
--- a/tests/wdio.conf.ts
+++ b/tests/wdio.conf.ts
@@ -166,14 +166,24 @@ export const config: WebdriverIO.MultiremoteConfig = {
/**
* Gets executed before test execution begins. At this point you can access to all global
* variables like `browser`. It is the perfect place to define custom commands.
+ * We have overriden this function in beforeSession to be able to pass cid as first param.
*
* @returns {Promise<void>}
*/
- async before() {
+ async before(cid, _, specs) {
+ if (specs.length !== 1) {
+ console.warn('We expect to run a single suite, but got more than one');
+ }
+
+ const testName = path.basename(specs[0]).replace('.spec.ts', '');
+
+ console.log(`Running test: ${testName} via worker: ${cid}`);
+
await Promise.all(multiremotebrowser.instances.map(async (instance: string) => {
const bInstance = multiremotebrowser.getInstance(instance);
- initLogger(bInstance, instance, TEST_RESULTS_DIR);
+ // @ts-ignore
+ initLogger(bInstance, `${instance}-${cid}-${testName}`, TEST_RESULTS_DIR);
if (bInstance.isFirefox) {
return;
@@ -204,6 +214,24 @@ export const config: WebdriverIO.MultiremoteConfig = {
}
},
+ beforeSession(c, capabilities, specs, cid) {
+ const originalBefore = c.before;
+
+ if (!originalBefore || !Array.isArray(originalBefore) || originalBefore.length !== 1) {
+ console.warn('No before hook found or more than one found, skipping');
+
+ return;
+ }
+
+ if (originalBefore) {
+ c.before = [ async function(...args) {
+ // Call original with cid as first param, followed by original args
+ // @ts-ignore
+ return await originalBefore[0].call(c, cid, ...args);
+ } ];
+ }
+ },
+
/**
* Gets executed before the suite starts (in Mocha/Jasmine only).
*