Skip to content

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

feat(tests): Uses memory logs on failure and stops logging during conference.

damenchoe82ef6de4b4e
diff --git a/conference.js b/conference.js
index 6922dcbcb2..18560a9120 100644
--- a/conference.js
+++ b/conference.js
@@ -1375,7 +1375,7 @@ export default {
}
APP.store.dispatch(updateRemoteParticipantFeatures(user));
- logger.log(`USER ${id} connected:`, user);
+ logger.log(`USER ${id} connected`);
APP.UI.addUser(user);
});
diff --git a/react/features/base/logging/middleware.ts b/react/features/base/logging/middleware.ts
index e7aa5bbafc..230aa134a0 100644
--- a/react/features/base/logging/middleware.ts
+++ b/react/features/base/logging/middleware.ts
@@ -186,6 +186,9 @@ function _initLogging({ dispatch, getState }: IStore,
Logger.addGlobalTransport(debugLogCollector);
JitsiMeetJS.addGlobalLogTransport(debugLogCollector);
debugLogCollector.start();
+
+ Logger.removeGlobalTransport(console);
+ JitsiMeetJS.removeGlobalLogTransport(console);
}
} else if (logCollector && loggingConfig.disableLogCollector) {
Logger.removeGlobalTransport(logCollector);
diff --git a/tests/helpers/browserLogger.ts b/tests/helpers/browserLogger.ts
index 6e3fa2fdb7..46bec40883 100644
--- a/tests/helpers/browserLogger.ts
+++ b/tests/helpers/browserLogger.ts
@@ -44,6 +44,25 @@ export function getLogs(driver: WebdriverIO.Browser) {
return fs.readFileSync(driver.logFile, 'utf8');
}
+/**
+ * Appends value to the log file.
+ * @param {WebdriverIO.Browser} driver - The driver which log file is requested.
+ * @param {string} value - The content to add to the file.
+ */
+export function saveLogs(driver: WebdriverIO.Browser, value: string) {
+ // @ts-ignore
+ if (!driver.logFile) {
+ return;
+ }
+
+ try {
+ // @ts-ignore
+ fs.appendFileSync(driver.logFile, value);
+ } catch (err) {
+ console.error(err);
+ }
+}
+
/**
* Logs a message in the logfile.
*
diff --git a/tests/wdio.conf.ts b/tests/wdio.conf.ts
index 30ee7b4b61..ea3daf7a03 100644
--- a/tests/wdio.conf.ts
+++ b/tests/wdio.conf.ts
@@ -9,7 +9,7 @@ import pretty from 'pretty';
import { getTestProperties, loadTestFiles } from './helpers/TestProperties';
import { config as testsConfig } from './helpers/TestsConfig';
import WebhookProxy from './helpers/WebhookProxy';
-import { getLogs, initLogger, logInfo } from './helpers/browserLogger';
+import { getLogs, initLogger, logInfo, saveLogs } from './helpers/browserLogger';
import { IContext } from './helpers/types';
import { generateRoomName } from './helpers/utils';
@@ -162,6 +162,18 @@ export const config: WebdriverIO.MultiremoteConfig = {
webdriver: 'info'
},
+ // Can be used to debug chromedriver, depends on chromedriver and wdio-chromedriver-service
+ // services: [
+ // [ 'chromedriver', {
+ // // Pass the --verbose flag to Chromedriver
+ // args: [ '--verbose' ],
+ // // Optionally, define a file to store the logs instead of stdout
+ // logFileName: 'wdio-chromedriver.log',
+ // // Optionally, define a directory for the log file
+ // outputDir: 'test-results',
+ // } ]
+ // ],
+
// Set directory to store all logs into
outputDir: TEST_RESULTS_DIR,
@@ -390,7 +402,14 @@ export const config: WebdriverIO.MultiremoteConfig = {
'text/plain'))
.catch(e => console.error('Failed grabbing debug logs', e)));
- AllureReporter.addAttachment(`console-logs-${instance}`, getLogs(bInstance) || '', 'text/plain');
+ allProcessing.push(
+ bInstance.execute(() => APP?.debugLogs?.logs?.join('\n')).then(res => {
+ if (res) {
+ saveLogs(bInstance, res);
+ }
+
+ AllureReporter.addAttachment(`console-logs-${instance}`, getLogs(bInstance) || '', 'text/plain');
+ }));
allProcessing.push(bInstance.getPageSource().then(source => {
AllureReporter.addAttachment(`html-source-${instance}`, pretty(source), 'text/plain');