From db416159570c0a70fe323339bfba1d347c150d7f Mon Sep 17 00:00:00 2001
From: golgetahir <tahir.golge@gmail.com>
Date: Tue, 18 Feb 2025 16:38:36 +0300
Subject: [PATCH 01/11] Fix camera on/off notification

---
 react/src/Components/Footer/Components/CameraButton.js | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/react/src/Components/Footer/Components/CameraButton.js b/react/src/Components/Footer/Components/CameraButton.js
index 26f0e924..7a5e0f57 100644
--- a/react/src/Components/Footer/Components/CameraButton.js
+++ b/react/src/Components/Footer/Components/CameraButton.js
@@ -20,10 +20,10 @@ function CameraButton(props) {
         <div style={{ display: "flex", alignItems: "center", gap: 8 }}>
           <SvgIcon
               size={24}
-              name={isTurningOff ? "camera-off" : "camera"}
+              name={isTurningOff ? "camera" : "camera-off"}
               color="#fff"
           />
-          {isTurningOff ? t("Camera turned off") : t("Camera turned on")}
+          {isTurningOff ? t("Camera turned on") : t("Camera turned off")}
         </div>
     );
 

From f2697f8fe4e28db68114cc2ff03e2ceab58ea9d7 Mon Sep 17 00:00:00 2001
From: golgetahir <tahir.golge@gmail.com>
Date: Wed, 19 Feb 2025 11:41:53 +0300
Subject: [PATCH 02/11] Update eslint file to reduce unnecessary warnings

---
 react/.eslintrc.js | 26 ++++++++++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)

diff --git a/react/.eslintrc.js b/react/.eslintrc.js
index b1673e7d..c9515a81 100644
--- a/react/.eslintrc.js
+++ b/react/.eslintrc.js
@@ -1,8 +1,30 @@
 module.exports = {
+    env: {
+        browser: true,
+        es6: true,
+        node: true
+    },
+    extends: [
+        'eslint:recommended',
+        'plugin:react/recommended'
+    ],
     plugins: [
-        'react-compiler',
+        'react',
+        'react-compiler'
     ],
+    parserOptions: {
+        ecmaVersion: 2020,
+        sourceType: 'module',
+        ecmaFeatures: {
+            jsx: true
+        }
+    },
     rules: {
-        'react-compiler/react-compiler': 'error',
+        'react-compiler/react-compiler': 'error'
     },
+    settings: {
+        react: {
+            version: 'detect'
+        }
+    }
 };
\ No newline at end of file

From bc5de002800b7f16aefb61d00a73f6ca4bc7a69a Mon Sep 17 00:00:00 2001
From: golgetahir <tahir.golge@gmail.com>
Date: Wed, 19 Feb 2025 11:50:15 +0300
Subject: [PATCH 03/11] Remove breaking rules in eslint

---
 react/.eslintrc.js | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/react/.eslintrc.js b/react/.eslintrc.js
index c9515a81..3ad9d5c1 100644
--- a/react/.eslintrc.js
+++ b/react/.eslintrc.js
@@ -4,10 +4,6 @@ module.exports = {
         es6: true,
         node: true
     },
-    extends: [
-        'eslint:recommended',
-        'plugin:react/recommended'
-    ],
     plugins: [
         'react',
         'react-compiler'

From 1be209e4ec05c47d223c1b645124fb8f09e1e145 Mon Sep 17 00:00:00 2001
From: golgetahir <tahir.golge@gmail.com>
Date: Sun, 23 Feb 2025 22:26:32 +0300
Subject: [PATCH 04/11] Fix the unnecessary creation of another webrtc adaptor

---
 react/src/pages/AntMedia.js | 27 ++++++++++++++++++++++++---
 1 file changed, 24 insertions(+), 3 deletions(-)

diff --git a/react/src/pages/AntMedia.js b/react/src/pages/AntMedia.js
index 6e5f0a27..3d8a295d 100644
--- a/react/src/pages/AntMedia.js
+++ b/react/src/pages/AntMedia.js
@@ -457,6 +457,20 @@ function AntMedia(props) {
     const speedTestCounter = React.useRef(0);
     const speedTestForPlayWebRtcAdaptor = React.useRef(null);
     const statsList = React.useRef([]);
+    const isFirstRunForPlayOnly = React.useRef(true);
+
+
+    // Added this debug function to catch the getUserMedia calls
+    const debugGetUserMedia = () => {
+        const oldGetUserMedia = navigator.mediaDevices.getUserMedia;
+        navigator.mediaDevices.getUserMedia = function() {
+            console.trace("getUserMedia called");
+            return oldGetUserMedia.apply(this, arguments);
+        };
+    };
+    React.useEffect(() => {
+        debugGetUserMedia();
+    }, []);
 
     // video send resolution for publishing
     // possible values: "auto", "highDefinition", "standartDefinition", "lowDefinition"
@@ -1378,9 +1392,9 @@ function AntMedia(props) {
                 debug: true,
                 callback: infoCallback,
                 callbackError: errorCallback,
-                purposeForTest: "main-adaptor"
+                purposeForTest: "main-adaptor",
             });
-            setWebRTCAdaptor(adaptor)
+            setWebRTCAdaptor(adaptor);
         });
     }
 
@@ -2275,6 +2289,13 @@ function AntMedia(props) {
     }, [role]);
 
     React.useEffect(() => {
+        // All React hooks are executed at the first render of the component.
+        // So, this function creates another webRTCAdaptor instance at the first run.
+        // This solution is a common pattern but we might need to question why our effect is problematic at the first run.
+        if (isFirstRunForPlayOnly.current) {
+            isFirstRunForPlayOnly.current = false;
+            return;
+        }
         // we need to empty participant array. if we are going to leave it in the first place.
         setVideoTrackAssignments([]);
         setAllParticipants({});
@@ -2298,7 +2319,7 @@ function AntMedia(props) {
         }
 
         createWebRTCAdaptor();
-
+        
         setWaitingOrMeetingRoom("waiting");
     }, [isPlayOnly]);
 

From cea66145cbdc1e523e1e420f5be5ae9ba890112b Mon Sep 17 00:00:00 2001
From: golgetahir <tahir.golge@gmail.com>
Date: Sun, 23 Feb 2025 22:30:52 +0300
Subject: [PATCH 05/11] Delete whitespace

---
 react/src/pages/AntMedia.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/react/src/pages/AntMedia.js b/react/src/pages/AntMedia.js
index 3d8a295d..aa289e3d 100644
--- a/react/src/pages/AntMedia.js
+++ b/react/src/pages/AntMedia.js
@@ -2319,7 +2319,7 @@ function AntMedia(props) {
         }
 
         createWebRTCAdaptor();
-        
+
         setWaitingOrMeetingRoom("waiting");
     }, [isPlayOnly]);
 

From f631f7a7ac91eabe8e6abce12f6f10a4890a70a7 Mon Sep 17 00:00:00 2001
From: golgetahir <tahir.golge@gmail.com>
Date: Mon, 24 Feb 2025 17:26:57 +0300
Subject: [PATCH 06/11] Add tests for the play only effect

---
 react/src/__tests__/pages/AntMedia.test.js | 121 ++++++++++++++++++++-
 react/src/pages/AntMedia.js                |  23 ++--
 2 files changed, 132 insertions(+), 12 deletions(-)

diff --git a/react/src/__tests__/pages/AntMedia.test.js b/react/src/__tests__/pages/AntMedia.test.js
index 89a0cbe1..2a879e93 100644
--- a/react/src/__tests__/pages/AntMedia.test.js
+++ b/react/src/__tests__/pages/AntMedia.test.js
@@ -17,7 +17,16 @@ import { assert } from 'workbox-core/_private';
 var webRTCAdaptorConstructor, webRTCAdaptorScreenConstructor, webRTCAdaptorPublishSpeedTestPlayOnlyConstructor, webRTCAdaptorPublishSpeedTestConstructor, webRTCAdaptorPlaySpeedTestConstructor;
 var currentConference;
 var websocketURL = "ws://localhost:5080/Conference/websocket";
-
+var oldAdaptor;
+
+// We'll store references here for easy access in tests
+const createdAdaptors = {
+  main: [],
+  screen: [],
+  publishSpeedTest: [],
+  publishSpeedTestPlayOnly: [],
+  playSpeedTest: []
+};
 jest.mock('Components/WebSocketProvider', () => ({
   ...jest.requireActual('Components/WebSocketProvider'),
   useWebSocket: jest.fn(),
@@ -96,6 +105,14 @@ jest.mock('@antmedia/webrtc_adaptor', () => ({
       joinRoom: jest.fn(),
       getSubtrackCount: jest.fn(),
       setVolumeLevel: jest.fn(),
+      mediaManager: {
+        localStream: {
+          getTracks: () => [],
+          getVideoTracks: () => []
+        }
+      },
+      getUserMedia: jest.fn().mockResolvedValue({}),
+      checkWebRTCPermissions: jest.fn().mockResolvedValue(true)
     }
 
     for (var key in params) {
@@ -104,20 +121,30 @@ jest.mock('@antmedia/webrtc_adaptor', () => ({
       }
     }
 
+    // If we test the methods that creates new adaptor on the fly we might need to keep the old adaptor for comparison
+    if (createdAdaptors.main.length > 0) {
+      oldAdaptor = createdAdaptors.main[createdAdaptors.main.length - 1];
+    }
+
     if (params.purposeForTest === "main-adaptor") {
       webRTCAdaptorConstructor = mockAdaptor;
+      createdAdaptors.main.push(mockAdaptor);
     }
     else if(params.purposeForTest === "screen-share") {
       webRTCAdaptorScreenConstructor = mockAdaptor;
+      createdAdaptors.screen.push(mockAdaptor);
     }
     else if (params.purposeForTest === "publish-speed-test-play-only") {
       webRTCAdaptorPublishSpeedTestPlayOnlyConstructor = mockAdaptor;
+      createdAdaptors.publishSpeedTestPlayOnly.push(mockAdaptor);
     }
     else if (params.purposeForTest === "publish-speed-test") {
       webRTCAdaptorPublishSpeedTestConstructor = mockAdaptor;
+      createdAdaptors.publishSpeedTest.push(mockAdaptor);
     }
     else if (params.purposeForTest === "play-speed-test") {
       webRTCAdaptorPlaySpeedTestConstructor = mockAdaptor;
+      createdAdaptors.playSpeedTest.push(mockAdaptor);
     }
     return mockAdaptor;
   }),
@@ -3564,6 +3591,98 @@ describe('AntMedia Component', () => {
   });
    */
 
+  it('should not run playOnly effect on initial mount', async () => {
+    const { container } = render(
+        <ThemeProvider theme={theme(ThemeList.Green)}>
+            <AntMedia isTest={true}>
+                <MockChild/>
+            </AntMedia>
+        </ThemeProvider>
+    );
+
+    await waitFor(() => {
+        expect(webRTCAdaptorConstructor).not.toBe(undefined);
+    });
+
+    // Verify initial mount doesn't trigger the effect's main logic
+    expect(webRTCAdaptorConstructor.stop).not.toHaveBeenCalled();
+    expect(webRTCAdaptorConstructor.turnOffLocalCamera).not.toHaveBeenCalled();
+    expect(webRTCAdaptorConstructor.closeStream).not.toHaveBeenCalled();
+});
+
+  it('should run playOnly effect when isPlayOnly changes after mount', async () => {
+
+    const mockLocalStorage = {
+      getItem: jest.fn().mockImplementation((key) => {
+          if (key === 'selectedCamera') return 'camera1'; 
+          if (key === 'selectedMicrophone') return 'microphone1';
+          return null;
+      }),
+      setItem: jest.fn()
+    };
+    Object.defineProperty(window, 'localStorage', { value: mockLocalStorage });
+      
+    mediaDevicesMock.enumerateDevices.mockResolvedValue([
+        { deviceId: 'camera1', kind: 'videoinput' },
+        { deviceId: 'microphone1', kind: 'audioinput' }
+    ]);
+
+    const { render1 } = render(
+        <ThemeProvider theme={theme(ThemeList.Green)}>
+            <AntMedia isTest={true} isPlayOnly={false}>
+                <MockChild/>
+            </AntMedia>
+        </ThemeProvider>
+    );
+
+    await waitFor(() => {
+      expect(webRTCAdaptorConstructor).not.toBe(undefined);
+    });
+
+    await act(async () => {
+      currentConference.setIsPlayOnly(true);
+    });
+
+    await waitFor(() => {
+      console.log('Initadasdasdasdad:', createdAdaptors.main.length);
+
+      //We need to check the old adaptor's methods to be able to test this effect because old adaptor is being stopped and new one will be created. However our initialization is done and timing is not working if we try to test directly webrtcAdaptorConstructor here.
+      expect(oldAdaptor.stop).toHaveBeenCalled();
+      expect(oldAdaptor.turnOffLocalCamera).toHaveBeenCalled();
+      expect(oldAdaptor.closeStream).toHaveBeenCalled();
+    });
+  });
+
+  it('should clear participants and intervals when isPlayOnly changes', async () => {
+      const { rerender } = render(
+          <ThemeProvider theme={theme(ThemeList.Green)}>
+              <AntMedia isTest={true} isPlayOnly={false}>
+                  <MockChild/>
+              </AntMedia>
+          </ThemeProvider>
+      );
+
+      await waitFor(() => {
+          expect(webRTCAdaptorConstructor).not.toBe(undefined);
+      });
+
+      // Set some initial participants
+      await act(async () => {
+          currentConference.setVideoTrackAssignments(['track1', 'track2']);
+          currentConference.setAllParticipants({ participant1: {}, participant2: {} });
+      });
+      
+      await act(async () => {
+        currentConference.setIsPlayOnly(true);
+      });
+
+      // Verify participants are cleared
+      await waitFor(() => {
+          expect(currentConference.videoTrackAssignments).toEqual([]);
+          expect(currentConference.allParticipants).toEqual({});
+      });
+  });
+
   it('starts becoming publisher if in play only mode', async () => {
     const {container} = render(
         <ThemeProvider theme={theme(ThemeList.Green)}>
diff --git a/react/src/pages/AntMedia.js b/react/src/pages/AntMedia.js
index 26fd1413..559f2b3d 100644
--- a/react/src/pages/AntMedia.js
+++ b/react/src/pages/AntMedia.js
@@ -1398,17 +1398,17 @@ function AntMedia(props) {
     }
 
     useEffect(() => {
-    if(!initialized)
-        return;
-  
-    if (devices.length > 0) {
-        console.log("updating audio video sources");
-        checkAndUpdateVideoAudioSources();
-    } else {
-        navigator.mediaDevices.enumerateDevices().then(devices => {
-            setDevices(devices);
-        });
-    }
+        if(!initialized)
+            return;
+    
+        if (devices.length > 0) {
+            console.log("updating audio video sources");
+            checkAndUpdateVideoAudioSources();
+        } else {
+            navigator.mediaDevices.enumerateDevices().then(devices => {
+                setDevices(devices);
+            });
+        }
     }, [devices,initialized]); // eslint-disable-line 
 
     if (webRTCAdaptor) {
@@ -3406,6 +3406,7 @@ function AntMedia(props) {
                     checkVideoTrackHealth,
                     setInitialized,
                     currentPinInfo,
+                    setAllParticipants,
                     unpinVideo
                 }}
             >

From 8892f892cd25a980ea7e762d1b5bb68e7ded2c4e Mon Sep 17 00:00:00 2001
From: golgetahir <tahir.golge@gmail.com>
Date: Tue, 4 Mar 2025 13:15:03 +0300
Subject: [PATCH 07/11] Fix unit tests, resolve interdependency and fix the
 release of the resources

---
 react/src/__tests__/pages/AntMedia.test.js | 1609 +++++++++++++-------
 1 file changed, 1063 insertions(+), 546 deletions(-)

diff --git a/react/src/__tests__/pages/AntMedia.test.js b/react/src/__tests__/pages/AntMedia.test.js
index 15395036..616d733a 100644
--- a/react/src/__tests__/pages/AntMedia.test.js
+++ b/react/src/__tests__/pages/AntMedia.test.js
@@ -15,8 +15,6 @@ import {WebinarRoles} from "../../WebinarRoles";
 import { assert } from 'workbox-core/_private';
 
 var webRTCAdaptorConstructor, webRTCAdaptorScreenConstructor, webRTCAdaptorPublishSpeedTestPlayOnlyConstructor, webRTCAdaptorPublishSpeedTestConstructor, webRTCAdaptorPlaySpeedTestConstructor;
-var currentConference;
-var websocketURL = "ws://localhost:5080/Conference/websocket";
 var oldAdaptor;
 
 // We'll store references here for easy access in tests
@@ -27,6 +25,7 @@ const createdAdaptors = {
   publishSpeedTestPlayOnly: [],
   playSpeedTest: []
 };
+
 jest.mock('Components/WebSocketProvider', () => ({
   ...jest.requireActual('Components/WebSocketProvider'),
   useWebSocket: jest.fn(),
@@ -46,91 +45,77 @@ jest.mock('utils', () => ({
 jest.mock('react-router-dom', () => ({
   ...jest.requireActual('react-router-dom'),
   useParams: jest.fn().mockReturnValue({id: "room"}),
-
 }));
 
-
+// Move this mock to ensure it's consistently available and reset between tests
 jest.mock('@antmedia/webrtc_adaptor', () => ({
-  ...jest.requireActual('@antmedia/webrtc_adaptor'),
   WebRTCAdaptor: jest.fn().mockImplementation((params) => {
-    console.log(params);
-    var mockAdaptor = {
-      init : jest.fn(),
-      publish : jest.fn().mockImplementation(() => console.log('publishhhhhh')),
-      play : jest.fn(),
-      unpublish : jest.fn(),
-      leaveRoom : jest.fn(),
-      startPublishing : jest.fn(),
-      stopPublishing : jest.fn(),
-      startPlaying : jest.fn(),
-      stopPlaying : jest.fn(),
-      getLocalStream : jest.fn(),
-      applyConstraints : jest.fn(),
-      sendData : jest.fn().mockImplementation((publishStreamId, data) => console.log('send data called with ')),
-      setMaxVideoTrackCount : jest.fn(),
-      enableStats : jest.fn(),
-      getBroadcastObject : jest.fn(),
-      checkWebSocketConnection : jest.fn(),
-      stop : jest.fn(),
-      turnOffLocalCamera : jest.fn(),
-      muteLocalMic: jest.fn(),
-      switchVideoCameraCapture: jest.fn(),
-      switchAudioInputSource: jest.fn(),
-      displayMessage: jest.fn(),
-      setMicrophoneButtonDisabled: jest.fn(),
-      setCameraButtonDisabled: jest.fn(),
-      setSelectedDevices: jest.fn(),
-      checkAndTurnOffLocalCamera: jest.fn(),
-      devices: [],
-      updateStreamMetaData: jest.fn(),
-      assignVideoTrack: jest.fn(),
-      setParticipantUpdated: jest.fn(),
-      getSubtracks: jest.fn(),
-      createSpeedTestForPublishWebRtcAdaptorPlayOnly: jest.fn(),
-      createSpeedTestForPublishWebRtcAdaptor: jest.fn(),
-      createSpeedTestForPlayWebRtcAdaptor: jest.fn(),
+    const mockAdaptor = {
+      publish: jest.fn(),
+      join: jest.fn(),
+      leave: jest.fn(),
+      stop: jest.fn(),
+      play: jest.fn(),
       requestVideoTrackAssignments: jest.fn(),
-      stopSpeedTest: jest.fn().mockImplementation(() => console.log('stopSpeedTest')),
-      closeStream: jest.fn(),
-      closeWebSocket: jest.fn(),
-      playStats: {},
-      leaveFromRoom: jest.fn(),
-      enableEffect: jest.fn(),
-      setSelectedVideoEffect: jest.fn(),
+      getSubtracks: jest.fn(),
       setBlurEffectRange: jest.fn(),
-      sendMessage: jest.fn(),
-      updateParticipantRole: jest.fn(),
-      updateBroadcastRole: jest.fn(),
-      showInfoSnackbarWithLatency: jest.fn(),
-      joinRoom: jest.fn(),
-      getSubtrackCount: jest.fn(),
+      enableEffect: jest.fn(),
+      getStreamInfo: jest.fn(),
+      enableAudioLevelWhenMuted: jest.fn(),
+      enableStats: jest.fn(),
+      assignVideoTrack: jest.fn(),
       setVolumeLevel: jest.fn(),
-      mediaManager: {
-        localStream: {
-          getTracks: () => [],
-          getVideoTracks: () => []
-        }
-      },
-      getUserMedia: jest.fn().mockResolvedValue({}),
-      checkWebRTCPermissions: jest.fn().mockResolvedValue(true)
-    }
+      callback: () => {},
+      callbackError: () => {},
+      setDesktopwithCameraSource: jest.fn(),
+      switchDesktopCaptureWithCamera: jest.fn(),
+      updateStreamMetaData: jest.fn(),
+      switchVideoCameraCapture: jest.fn(),
+      openStream: jest.fn(),
+      muteLocalMic: jest.fn(),
+      getBroadcastObject: jest.fn(),
+      getSubtrackCount: jest.fn(),
+      unmuteLocalMic: jest.fn(),
+      joinRoom: jest.fn(),
+      setMaxVideoTrackCount: jest.fn(),      
+      closeStream: jest.fn(),
+      closeWebSocket: jest.fn(),
+      switchDesktopCapture: jest.fn(),
+      switchVideoCameraCapture: jest.fn(),
+      turnOnLocalCamera: jest.fn(),
+      turnOffLocalCamera: jest.fn(),
+      switchAudioInputSource: jest.fn(),
+      applyConstraints: jest.fn(),
+      getTracks: jest.fn(),
+      getVideoSender: jest.fn(),
+      getAudioSender: jest.fn(),
+      setVirtualBackgroundImage: jest.fn(),
+      addStreamCallback: jest.fn(),
+      getVideoTrack: jest.fn(),
+      updateVideoTrack: jest.fn(),
+      gotStream: jest.fn(),
+      getAudioTrack: jest.fn(),
+      changeBandwidth: jest.fn(),
+      getNoiseSuppressionFlag: jest.fn(),
+      getEchoCancellationFlag: jest.fn(),
+      getAutoGainControlFlag: jest.fn(),
+      enableAudioLevelWhenMuted: jest.fn(),
+      applyVideoEffect: jest.fn(),
+      updateAudioTrack: jest.fn(),
+      switchVideoCameraCapture: jest.fn(),
+      checkWebSocketConnection: jest.fn(),
+      sendData: jest.fn(),
+    };
 
-    for (var key in params) {
-      if (typeof params[key] === 'function') {
-        mockAdaptor[key] = params[key];
-      }
+    if (params.callback) {
+      mockAdaptor.callback = params.callback;
     }
-
-    // If we test the methods that creates new adaptor on the fly we might need to keep the old adaptor for comparison
-    if (createdAdaptors.main.length > 0) {
-      oldAdaptor = createdAdaptors.main[createdAdaptors.main.length - 1];
+    if (params.callbackError) {
+      mockAdaptor.callbackError = params.callbackError;
     }
 
-    if (params.purposeForTest === "main-adaptor") {
-      webRTCAdaptorConstructor = mockAdaptor;
-      createdAdaptors.main.push(mockAdaptor);
-    }
-    else if(params.purposeForTest === "screen-share") {
+    // Store the adaptor in the appropriate array based on purpose and set the global constructor variables
+    if (params.purposeForTest === "screen-share") {
       webRTCAdaptorScreenConstructor = mockAdaptor;
       createdAdaptors.screen.push(mockAdaptor);
     }
@@ -146,23 +131,40 @@ jest.mock('@antmedia/webrtc_adaptor', () => ({
       webRTCAdaptorPlaySpeedTestConstructor = mockAdaptor;
       createdAdaptors.playSpeedTest.push(mockAdaptor);
     }
+    else {
+      webRTCAdaptorConstructor = mockAdaptor;
+      createdAdaptors.main.push(mockAdaptor);
+    }
+    
     return mockAdaptor;
   }),
+  // Add the getUrlParameter function to the mock
+  getUrlParameter: jest.fn().mockImplementation((paramName) => {
+    // Return default mock values based on parameter name
+    if (paramName === "enterDirectly") return "false";
+    return null;
+  }),
+  VideoEffect: {
+    BLUR: "blur",
+    BACKGROUND_BLUR: "backgroundBlur",
+    NONE: "none"
+  }
 }));
 
 jest.mock('Components/Cards/VideoCard', () => ({ value }) => <div data-testid="mocked-video-card">{value}</div>);
 jest.mock('Components/EffectsDrawer', () => ({ value }) => <div data-testid="mocked-effect-drawer">{value}</div>);
 
-
-const MockChild = () => {
-  const conference = React.useContext(UnitTestContext);
-  currentConference = conference;
-
-  //console.log(conference);
-
-  return (
-      <div> My Mock </div>
-  );
+// Replace the global MockChild component with a function that creates a MockChild
+// This allows each test to have its own reference to the conference object
+const createMockChild = (setConference) => {
+  return () => {
+    const conference = React.useContext(UnitTestContext);
+    // Instead of directly mutating a global, we call the provided setter function
+    if (setConference) {
+      setConference(conference);
+    }
+    return <div>My Mock</div>;
+  };
 };
 
 const mediaDevicesMock = {
@@ -176,39 +178,57 @@ const mediaDevicesMock = {
 
 const enqueueSnackbar = jest.fn();
 
-global.navigator.mediaDevices = mediaDevicesMock; // here
-
 describe('AntMedia Component', () => {
+  // Local variables for this describe block
+  let currentConference;
 
   beforeEach(() => {
     console.log("---------------------------");
     console.log(`Starting test: ${expect.getState().currentTestName}`);
     // Reset the mock implementation before each test
     jest.clearAllMocks();
+    
+    // Clear any stored adaptors
+    createdAdaptors.main = [];
+    createdAdaptors.screen = [];
+    createdAdaptors.publishSpeedTest = [];
+    createdAdaptors.publishSpeedTestPlayOnly = [];
+    createdAdaptors.playSpeedTest = [];
+    
+    // Reset local conference reference
+    currentConference = undefined;
 
+    // Setup mock web socket
+    websocketSendMessage = jest.fn();
     useWebSocket.mockImplementation(() => ({
       return: {
-        sendMessage: jest.fn(),
+        sendMessage: websocketSendMessage,
         latestMessage: null,
         isWebSocketConnected: true,
       }
     }));
 
+    // Setup mock snackbar
     useSnackbar.mockImplementation(() => ({
       enqueueSnackbar: enqueueSnackbar,
       closeSnackbar: jest.fn(),
     }));
+    
+    // Set up navigator.mediaDevices for each test
+    global.navigator.mediaDevices = { ...mediaDevicesMock };
   });
 
   afterEach(() => {
     webRTCAdaptorConstructor = undefined;
     webRTCAdaptorScreenConstructor = undefined;
+    webRTCAdaptorPublishSpeedTestPlayOnlyConstructor = undefined;
+    webRTCAdaptorPublishSpeedTestConstructor = undefined;
+    webRTCAdaptorPlaySpeedTestConstructor = undefined;
     currentConference = undefined;
     console.log(`Finished test: ${expect.getState().currentTestName}`);
     console.log("---------------------------");
   });
 
-
   it('renders without crashing', async () => {
     await act(async () => {
       const { container } = render(
@@ -216,20 +236,24 @@ describe('AntMedia Component', () => {
       );
       console.log(container.outerHTML);
     });
-
   });
 
   it('share screen', async () => {
+    // Create a local conference reference for this test
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
+
     const { container } = render(
         <AntMedia isTest={true}>
-          <MockChild/>
+          <TestMockChild/>
         </AntMedia>);
-    //console.log(container);
 
-    expect(currentConference.isScreenShared).toBe(false);
+    expect(testConference.isScreenShared).toBe(false);
 
     await act(async () => {
-      currentConference.handleStartScreenShare();
+      testConference.handleStartScreenShare();
     });
 
     await waitFor(() => {
@@ -240,40 +264,43 @@ describe('AntMedia Component', () => {
       webRTCAdaptorScreenConstructor.callback("publish_started");
     });
 
-
     await waitFor(() => {
-      expect(currentConference.isScreenShared).toBe(true);
+      expect(testConference.isScreenShared).toBe(true);
     });
 
-    console.log(currentConference);
+    console.log(testConference);
 
-    expect(currentConference.isScreenShared).toBe(true);
+    expect(testConference.isScreenShared).toBe(true);
 
     await act(()=> {
-      currentConference.handleStopScreenShare();
+      testConference.handleStopScreenShare();
     });
 
     expect(webRTCAdaptorScreenConstructor.closeStream).toHaveBeenCalled();
     expect(webRTCAdaptorScreenConstructor.closeWebSocket).toHaveBeenCalled();
-
-
   });
 
+
   it('share screen adaptor callbacks', async () => {
+    // Create a local conference reference for this test
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
 
     const consoleSpy = jest.spyOn(console, 'log').mockImplementation();
 
     const { container } = render(
         <AntMedia isTest={true}>
-          <MockChild/>
+          <TestMockChild/>
         </AntMedia>);
     //console.log(container);
 
 
-    expect(currentConference.isScreenShared).toBe(false);
+    expect(testConference.isScreenShared).toBe(false);
 
     await act(async () => {
-      currentConference.handleStartScreenShare();
+      testConference.handleStartScreenShare();
     });
 
     await waitFor(() => {
@@ -356,9 +383,14 @@ describe('AntMedia Component', () => {
 
 
   it('handle sharing on', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
+
     const { container } = render(
         <AntMedia isTest={true}>
-          <MockChild/>
+          <TestMockChild/>
         </AntMedia>);
 
     await waitFor(() => {
@@ -367,7 +399,7 @@ describe('AntMedia Component', () => {
 
     var testStreamId = "stream1";
 
-    currentConference.videoTrackAssignments.push({streamId: testStreamId, videoLabel: "test1"});
+    testConference.videoTrackAssignments.push({streamId: testStreamId, videoLabel: "test1"});
     var obj = {};
     var notificationEvent = {
       eventType: "SCREEN_SHARED_ON",
@@ -384,9 +416,13 @@ describe('AntMedia Component', () => {
   });
 
   it('publishTimeoutError error callback', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
     const { container } = render(
         <AntMedia isTest={true}>
-          <MockChild/>
+          <TestMockChild/>
         </AntMedia>);
 
     const consoleSpy = jest.spyOn(console, 'error').mockImplementation();
@@ -400,20 +436,25 @@ describe('AntMedia Component', () => {
     });
 
     await act(async () => {
-      expect(currentConference.leaveRoomWithError == "Firewall might be blocking your connection. Please report this.");
+      expect(testConference.leaveRoomWithError == "Firewall might be blocking your connection. Please report this.");
     });
 
     await act(async () => {
-      expect(currentConference.leftTheRoom == true);
+      expect(testConference.leftTheRoom == true);
     });
 
     consoleSpy.mockRestore();
   });
 
   it('license_suspended_please_renew_license error callback', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
+
     const { container } = render(
         <AntMedia isTest={true}>
-          <MockChild/>
+          <TestMockChild/>
         </AntMedia>);
 
     const consoleSpy = jest.spyOn(console, 'error').mockImplementation();
@@ -435,9 +476,14 @@ describe('AntMedia Component', () => {
   });
 
   it('notSetRemoteDescription error callback', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
+
     const { container } = render(
         <AntMedia isTest={true}>
-          <MockChild/>
+          <TestMockChild/>
         </AntMedia>);
 
     const consoleSpy = jest.spyOn(console, 'error').mockImplementation();
@@ -459,9 +505,14 @@ describe('AntMedia Component', () => {
   });
 
   it('max video count setting', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
+
     const { container } = render(
         <AntMedia isTest={true}>
-          <MockChild/>
+          <TestMockChild/>
         </AntMedia>);
 
     const consoleSpy = jest.spyOn(console, 'error').mockImplementation();
@@ -471,23 +522,23 @@ describe('AntMedia Component', () => {
     });
 
     await waitFor(() => {
-      currentConference.joinRoom("room", "publishStreamId");
+      testConference.joinRoom("room", "publishStreamId");
     });
 
     await act(async () => {
-      currentConference.handleSetDesiredTileCount(5);
+      testConference.handleSetDesiredTileCount(5);
     });
 
     await waitFor(() => {
-      expect(currentConference.globals.desiredTileCount).toBe(5);
+      expect(testConference.globals.desiredTileCount).toBe(5);
     });
 
     await act(async () => {
-      currentConference.updateMaxVideoTrackCount(7);
+      testConference.updateMaxVideoTrackCount(7);
     });
 
     await waitFor(() => {
-      expect(currentConference.globals.maxVideoTrackCount).toBe(7);
+      expect(testConference.globals.maxVideoTrackCount).toBe(7);
     });
 
     consoleSpy.mockRestore();
@@ -495,6 +546,10 @@ describe('AntMedia Component', () => {
   });
 
   it('start with camera and microphone', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
     mediaDevicesMock.enumerateDevices.mockResolvedValue([
       { deviceId: '1', kind: 'videoinput' },
       { deviceId: '1', kind: 'audioinput' },
@@ -502,63 +557,82 @@ describe('AntMedia Component', () => {
 
     const { container } = render(
         <AntMedia isTest={true}>
-          <MockChild/>
+          <TestMockChild/>
         </AntMedia>);
 
-    expect(currentConference.cameraButtonDisabled === false);
-    expect(currentConference.microphoneButtonDisabled === false);
+    expect(testConference.cameraButtonDisabled === false);
+    expect(testConference.microphoneButtonDisabled === false);
 
   });
 
   it('start with one microphone and without any camera', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
+
     mediaDevicesMock.enumerateDevices.mockResolvedValue([
       { deviceId: '1', kind: 'audioinput' },
     ]);
 
     const { container } = render(
         <AntMedia isTest={true}>
-          <MockChild/>
+          <TestMockChild/>
         </AntMedia>);
 
-    expect(currentConference.cameraButtonDisabled === true);
-    expect(currentConference.microphoneButtonDisabled === false);
+    expect(testConference.cameraButtonDisabled === true);
+    expect(testConference.microphoneButtonDisabled === false);
 
   });
 
   it('start with one camera and without any microphone', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
+
     mediaDevicesMock.enumerateDevices.mockResolvedValue([
       { deviceId: '1', kind: 'videoinput' },
     ]);
 
     const { container } = render(
         <AntMedia isTest={true}>
-          <MockChild/>
+          <TestMockChild/>
         </AntMedia>);
 
-    expect(currentConference.cameraButtonDisabled === false);
-    expect(currentConference.microphoneButtonDisabled === true);
+    expect(testConference.cameraButtonDisabled === false);
+    expect(testConference.microphoneButtonDisabled === true);
 
   });
 
   it('start without camera nor microphone', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
+
     mediaDevicesMock.enumerateDevices.mockResolvedValue([
     ]);
 
     const { container } = render(
         <AntMedia isTest={true}>
-          <MockChild/>
+          <TestMockChild/>
         </AntMedia>);
 
-    expect(currentConference.cameraButtonDisabled === true);
-    expect(currentConference.microphoneButtonDisabled === true);
+    expect(testConference.cameraButtonDisabled === true);
+    expect(testConference.microphoneButtonDisabled === true);
 
   });
 
   it('should enable camera and microphone buttons if selected devices are available', async () => {
+    let testConference;   
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
 
     const { container } = render(
         <AntMedia isTest={true}>
-          <MockChild/>
+          <TestMockChild/>
         </AntMedia>);
 
 
@@ -568,19 +642,23 @@ describe('AntMedia Component', () => {
 
     // Execute the function
     await act(async () => {
-      currentConference.checkAndUpdateVideoAudioSources();
+      testConference.checkAndUpdateVideoAudioSources();
     });
 
     // Expectations
-    expect(currentConference.cameraButtonDisabled === false);
-    expect(currentConference.microphoneButtonDisabled === false);
+    expect(testConference.cameraButtonDisabled === false);
+    expect(testConference.microphoneButtonDisabled === false);
   });
 
   it('should disable microphone button if no microphone is available', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
 
     const { container } = render(
         <AntMedia isTest={true}>
-          <MockChild/>
+          <TestMockChild/>
         </AntMedia>);
 
 
@@ -593,13 +671,13 @@ describe('AntMedia Component', () => {
       {videoDeviceId: '2'},
     ]);
 
-    currentConference.devices = [];
+    testConference.devices = [];
 
     const consoleSpy = jest.spyOn(console, 'info').mockImplementation();
 
     // Execute the function
     await act(async () => {
-      currentConference.checkAndUpdateVideoAudioSources();
+      testConference.checkAndUpdateVideoAudioSources();
     });
 
     // Expectations
@@ -608,9 +686,14 @@ describe('AntMedia Component', () => {
   });
 
   it('should disable microphone button if no microphone is available', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
+
     const { container } = render(
         <AntMedia isTest={true}>
-          <MockChild/>
+          <TestMockChild/>
         </AntMedia>);
 
 
@@ -624,13 +707,13 @@ describe('AntMedia Component', () => {
       {audioDeviceId: '2'},
     ]);
 
-    currentConference.devices = [];
+    testConference.devices = [];
 
     const consoleSpy = jest.spyOn(console, 'info').mockImplementation();
 
     // Execute the function
     await act(async () => {
-      currentConference.checkAndUpdateVideoAudioSources();
+      testConference.checkAndUpdateVideoAudioSources();
     });
 
     // Expectations
@@ -639,13 +722,18 @@ describe('AntMedia Component', () => {
   });
 
   it('should switching the first available camera due to selected camera is not available', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
+
     mediaDevicesMock.enumerateDevices.mockResolvedValue([
       { deviceId: 'camera2', kind: 'videoinput' },
     ]);
 
     const { container } = render(
         <AntMedia isTest={true}>
-          <MockChild/>
+          <TestMockChild/>
         </AntMedia>);
 
     await waitFor(() => {
@@ -659,20 +747,20 @@ describe('AntMedia Component', () => {
     });
 
     await act(async () => {
-      currentConference.setSelectedCamera("camera1");
+      testConference.setSelectedCamera("camera1");
     });
 
     await waitFor(() => {
-      expect(currentConference.selectedCamera).toBe("camera1");
+      expect(testConference.selectedCamera).toBe("camera1");
     });
 
     const consoleSpy = jest.spyOn(console, 'info').mockImplementation();
 
-    console.log(currentConference.getSelectedDevices());
+    console.log(testConference.getSelectedDevices());
 
     // Execute the function
     await act(async () => {
-      currentConference.checkAndUpdateVideoAudioSources();
+      testConference.checkAndUpdateVideoAudioSources();
     });
 
     // Expectations
@@ -682,13 +770,18 @@ describe('AntMedia Component', () => {
 
 
   it('should switching the first available microphone due to selected microphone is not available', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
+
     mediaDevicesMock.enumerateDevices.mockResolvedValue([
       { deviceId: 'mic2', kind: 'audioinput' },
     ]);
 
     const { container } = render(
         <AntMedia isTest={true}>
-          <MockChild/>
+          <TestMockChild/>
         </AntMedia>);
 
     await waitFor(() => {
@@ -702,20 +795,20 @@ describe('AntMedia Component', () => {
     });
 
     await act(async () => {
-      currentConference.setSelectedMicrophone("mic1");
+      testConference.setSelectedMicrophone("mic1");
     });
 
     await waitFor(() => {
-      expect(currentConference.selectedMicrophone).toBe("mic1");
+      expect(testConference.selectedMicrophone).toBe("mic1");
     });
 
     const consoleSpy = jest.spyOn(console, 'info').mockImplementation();
 
-    console.log(currentConference.getSelectedDevices());
+    console.log(testConference.getSelectedDevices());
 
     // Execute the function
     await act(async () => {
-      currentConference.checkAndUpdateVideoAudioSources();
+      testConference.checkAndUpdateVideoAudioSources();
     });
 
     // Expectations
@@ -724,10 +817,15 @@ describe('AntMedia Component', () => {
   });
 
   it('is joining state test', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
+
     const { container } = render(
         <ThemeProvider theme={theme(ThemeList.Green)}>
           <AntMedia isTest={true}>
-            <MockChild/>
+            <TestMockChild/>
           </AntMedia>
         </ThemeProvider>);
 
@@ -736,15 +834,15 @@ describe('AntMedia Component', () => {
       expect(webRTCAdaptorConstructor).not.toBe(undefined);
     });
 
-    expect(currentConference.isJoining).toBe(false);
+    expect(testConference.isJoining).toBe(false);
 
     const consoleSpy = jest.spyOn(console, 'error').mockImplementation();
 
     await act(async () => {
-      currentConference.setIsJoining(true);
+      testConference.setIsJoining(true);
     });
 
-    expect(currentConference.isJoining).toBe(true);
+    expect(testConference.isJoining).toBe(true);
 
     await act(async () => {
       webRTCAdaptorConstructor.callback("publish_started");
@@ -755,17 +853,22 @@ describe('AntMedia Component', () => {
     });
 
 
-    expect(currentConference.isJoining).toBe(false);
+    expect(testConference.isJoining).toBe(false);
 
     consoleSpy.mockRestore();
 
   });
 
   it('is joining state for playonly', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
+
     const { container } = render(
         <ThemeProvider theme={theme(ThemeList.Green)}>
           <AntMedia isTest={true}>
-            <MockChild/>
+            <TestMockChild/>
           </AntMedia>
         </ThemeProvider>);
 
@@ -774,33 +877,38 @@ describe('AntMedia Component', () => {
       expect(webRTCAdaptorConstructor).not.toBe(undefined);
     });
 
-    expect(currentConference.isJoining).toBe(false);
+    expect(testConference.isJoining).toBe(false);
 
     const consoleSpy = jest.spyOn(console, 'error').mockImplementation();
 
     await act(async () => {
-      currentConference.setIsJoining(true);
-      currentConference.setIsPlayOnly(true);
+      testConference.setIsJoining(true);
+      testConference.setIsPlayOnly(true);
     });
 
-    expect(currentConference.isJoining).toBe(true);
+    expect(testConference.isJoining).toBe(true);
 
     await act(async () => {
       webRTCAdaptorConstructor.callback("play_started");
     });
 
 
-    expect(currentConference.isJoining).toBe(false);
+    expect(testConference.isJoining).toBe(false);
 
     consoleSpy.mockRestore();
 
   });
 
   it('playonly join when noone in the room', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
+
     const { container } = render(
         <ThemeProvider theme={theme(ThemeList.Green)}>
           <AntMedia isTest={true}>
-            <MockChild/>
+            <TestMockChild/>
           </AntMedia>
         </ThemeProvider>);
 
@@ -809,17 +917,17 @@ describe('AntMedia Component', () => {
       expect(webRTCAdaptorConstructor).not.toBe(undefined);
     });
 
-    expect(currentConference.isJoining).toBe(false);
+    expect(testConference.isJoining).toBe(false);
 
     const consoleSpy = jest.spyOn(console, 'error').mockImplementation();
 
     await act(async () => {
-      currentConference.setIsJoining(true);
-      currentConference.setIsPlayOnly(true);
+      testConference.setIsJoining(true);
+      testConference.setIsPlayOnly(true);
       webRTCAdaptorConstructor.callbackError("no_stream_exist");
     });
 
-    expect(currentConference.isJoining).toBe(true);
+    expect(testConference.isJoining).toBe(true);
 
     await waitFor(() => {
       expect(container.outerHTML).toContain("The room is currently empty");
@@ -830,17 +938,22 @@ describe('AntMedia Component', () => {
     });
 
 
-    expect(currentConference.isJoining).toBe(false);
+    expect(testConference.isJoining).toBe(false);
 
     consoleSpy.mockRestore();
 
   });
 
   it('is reconnection in progress state test', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
+
     const { container } = render(
         <ThemeProvider theme={theme(ThemeList.Green)}>
           <AntMedia isTest={true}>
-            <MockChild/>
+            <TestMockChild/>
           </AntMedia>
         </ThemeProvider>);
 
@@ -880,10 +993,15 @@ describe('AntMedia Component', () => {
   });
 
   it('is reconnection in progress state test because of publisher', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
+
     const { container } = render(
         <ThemeProvider theme={theme(ThemeList.Green)}>
           <AntMedia isTest={true}>
-            <MockChild/>
+            <TestMockChild/>
           </AntMedia>
         </ThemeProvider>);
 
@@ -930,10 +1048,15 @@ describe('AntMedia Component', () => {
   */
 
   it('check publisher stucks on reconnection issue', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
+
     const { container } = render(
         <ThemeProvider theme={theme(ThemeList.Green)}>
           <AntMedia isTest={true}>
-            <MockChild/>
+            <TestMockChild/>
           </AntMedia>
         </ThemeProvider>);
 
@@ -997,10 +1120,15 @@ describe('AntMedia Component', () => {
 
 
   it('is reconnection in progress state for playonly', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
+
     const { container } = render(
         <ThemeProvider theme={theme(ThemeList.Green)}>
           <AntMedia isTest={true}>
-            <MockChild/>
+            <TestMockChild/>
           </AntMedia>
         </ThemeProvider>);
 
@@ -1011,7 +1139,7 @@ describe('AntMedia Component', () => {
     expect(container.outerHTML).not.toContain("Reconnecting...");
 
     await act(async () => {
-      currentConference.setIsPlayOnly(true);
+      testConference.setIsPlayOnly(true);
     });
 
     await act(async () => {
@@ -1035,10 +1163,15 @@ describe('AntMedia Component', () => {
 
 
   it('test fix for duplicated tile after reconnection', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
+
     const { container } = render(
         <ThemeProvider theme={theme(ThemeList.Green)}>
           <AntMedia isTest={true}>
-            <MockChild/>
+            <TestMockChild/>
           </AntMedia>
         </ThemeProvider>);
 
@@ -1061,18 +1194,18 @@ describe('AntMedia Component', () => {
       expect(container.outerHTML).toContain("Reconnecting...");
     });
 
-    expect(currentConference.videoTrackAssignments).toHaveLength(1);
+    expect(testConference.videoTrackAssignments).toHaveLength(1);
 
-    expect(currentConference.videoTrackAssignments[0].isMine).toBe(true);
+    expect(testConference.videoTrackAssignments[0].isMine).toBe(true);
 
     await act(async () => {
       webRTCAdaptorConstructor.callback("newTrackAvailable", {"trackId" : "ARDAMSvvideoTrack0", "streamId":"room1", "track": {id: "someId", kind: "video"}});
     });
 
-    expect(currentConference.videoTrackAssignments).toHaveLength(2);
+    expect(testConference.videoTrackAssignments).toHaveLength(2);
 
-    expect(currentConference.videoTrackAssignments[1].videoLabel).toBe("videoTrack0");
-    expect(currentConference.videoTrackAssignments[1].streamId).toBe("room1");
+    expect(testConference.videoTrackAssignments[1].videoLabel).toBe("videoTrack0");
+    expect(testConference.videoTrackAssignments[1].streamId).toBe("room1");
 
 
     var notificationEvent = {
@@ -1090,14 +1223,19 @@ describe('AntMedia Component', () => {
       webRTCAdaptorConstructor.callback("data_received", obj);
     });
 
-    expect(currentConference.videoTrackAssignments).toHaveLength(2);
+    expect(testConference.videoTrackAssignments).toHaveLength(2);
 
-    expect(currentConference.videoTrackAssignments[1].videoLabel).toBe("videoTrack0");
-    expect(currentConference.videoTrackAssignments[1].streamId).toBe("participant1");
+    expect(testConference.videoTrackAssignments[1].videoLabel).toBe("videoTrack0");
+    expect(testConference.videoTrackAssignments[1].streamId).toBe("participant1");
 
   });
 
   it('calls removeAllRemoteParticipants without crashing', () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
+
     let contextValue = {
       removeAllRemoteParticipants: jest.fn(),
     };
@@ -1117,10 +1255,16 @@ describe('AntMedia Component', () => {
     expect(contextValue.removeAllRemoteParticipants).toHaveBeenCalled();
   });
 
-  it('handleLeaveFromRoom#closeStream', async () => { 
+  it('handleLeaveFromRoom#closeStream', async () => {
+    // Create a local reference for this test
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
+
     const { container } = render(
       <AntMedia isTest={true}>
-        <MockChild/>
+        <TestMockChild/>
       </AntMedia>);
 
     await waitFor(() => {
@@ -1131,40 +1275,40 @@ describe('AntMedia Component', () => {
     let publishStreamId = "publishStreamId";
 
     await act(async () => {
-      currentConference.setRoomName(roomName);
-    });
-
-    await act(async () => {
-      currentConference.setPublishStreamId(publishStreamId);
+      testConference.setRoomName(roomName);
     });
 
     await act(async () => {
-      process.env.REACT_APP_SHOW_PLAY_ONLY_PARTICIPANTS = 'true';
+      testConference.setPublishStreamId(publishStreamId);
     });
 
     await act(async () => {
-      currentConference.handleLeaveFromRoom();
+      testConference.handleLeaveFromRoom();
     });
 
-    expect(webRTCAdaptorConstructor.stop).toHaveBeenCalled();
     expect(webRTCAdaptorConstructor.closeStream).toHaveBeenCalled();
-
+    
+    expect(webRTCAdaptorConstructor.stop).toHaveBeenCalled();
   });
 
   it('screen sharing state test', async () => {
+    // Create a local reference for this test
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
+
     const { container } = render(
         <ThemeProvider theme={theme(ThemeList.Green)}>
           <AntMedia isTest={true}>
-            <MockChild/>
+            <TestMockChild/>
           </AntMedia>
         </ThemeProvider>);
 
-
-
-    expect(currentConference.isScreenShared).toBe(false);
+    expect(testConference.isScreenShared).toBe(false);
 
     await act(async () => {
-      currentConference.handleStartScreenShare();
+      testConference.handleStartScreenShare();
     });
 
     await waitFor(() => {
@@ -1184,10 +1328,15 @@ describe('AntMedia Component', () => {
   });
 
   it('screen sharing test', async () => {
+
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
     const {container} = render(
         <ThemeProvider theme={theme(ThemeList.Green)}>
           <AntMedia isTest={true}>
-            <MockChild/>
+            <TestMockChild/>
           </AntMedia>
         </ThemeProvider>);
 
@@ -1196,15 +1345,15 @@ describe('AntMedia Component', () => {
     });
 
     const consoleSpy = jest.spyOn(console, 'error').mockImplementation();
-    currentConference.setParticipantUpdated = jest.fn();
+    testConference.setParticipantUpdated = jest.fn();
 
-    currentConference.allParticipants["participant0"] = {videoTrackId: "participant0", isPinned: false};
-    currentConference.allParticipants["participant1"] = {videoTrackId: "participant1", isPinned: false};
-    currentConference.allParticipants["participant2"] = {videoTrackId: "participant2", isPinned: false};
-    currentConference.allParticipants["participant3"] = {videoTrackId: "participant3", isPinned: false};
+    testConference.allParticipants["participant0"] = {videoTrackId: "participant0", isPinned: false};
+    testConference.allParticipants["participant1"] = {videoTrackId: "participant1", isPinned: false};
+    testConference.allParticipants["participant2"] = {videoTrackId: "participant2", isPinned: false};
+    testConference.allParticipants["participant3"] = {videoTrackId: "participant3", isPinned: false};
 
     await act(async () => {
-      currentConference.setVideoTrackAssignments([
+      testConference.setVideoTrackAssignments([
         {videoLabel: "participant0", streamId: "participant0", videoTrackId: "participant0", audioTrackId: "participant0", isReserved: false},
         {videoLabel: "participant1", streamId: "participant1", videoTrackId: "participant1", audioTrackId: "participant1", isReserved: false},
         {videoLabel: "participant2", streamId: "participant2", videoTrackId: "participant2", audioTrackId: "participant2", isReserved: false},
@@ -1214,31 +1363,31 @@ describe('AntMedia Component', () => {
 
     // testing pinning
     await act(async () => {
-      currentConference.pinVideo("participant3");
+      testConference.pinVideo("participant3");
     });
 
     await waitFor(() => {
-      expect(currentConference.currentPinInfo.streamId).toBe('participant3');
+      expect(testConference.currentPinInfo.streamId).toBe('participant3');
     });
 
     // testing pinning while another participant is pinned
     await act(async () => {
-      currentConference.pinVideo("participant2");
+      testConference.pinVideo("participant2");
     });
 
-    expect(currentConference.currentPinInfo.streamId).toBe('participant2');
+    expect(testConference.currentPinInfo.streamId).toBe('participant2');
 
 
     // testing unpinning
     await act(async () => {
-      currentConference.unpinVideo();
+      testConference.unpinVideo();
     });
 
-    expect(currentConference.currentPinInfo).toBe(null);
+    expect(testConference.currentPinInfo).toBe(null);
 
     // testing pinning a non-existing participant
     await act(async () => {
-      currentConference.pinVideo("non-exist-participant");
+      testConference.pinVideo("non-exist-participant");
     });
 
     expect(consoleSpy).toHaveBeenCalledWith("Cannot find broadcast object for streamId: non-exist-participant");
@@ -1246,10 +1395,15 @@ describe('AntMedia Component', () => {
   });
 
   it('high resource usage', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
+
     const { container } = render(
         <ThemeProvider theme={theme(ThemeList.Green)}>
           <AntMedia isTest={true}>
-            <MockChild/>
+            <TestMockChild/>
           </AntMedia>
         </ThemeProvider>);
 
@@ -1260,10 +1414,10 @@ describe('AntMedia Component', () => {
 
     webRTCAdaptorConstructor.closeWebSocket = jest.fn();
 
-    expect(currentConference.isJoining).toBe(false);
+    expect(testConference.isJoining).toBe(false);
 
     await act(async () => {
-      currentConference.joinRoom("room", "publishStreamId");
+      testConference.joinRoom("room", "publishStreamId");
     });
 
     await act(async () => {
@@ -1280,10 +1434,15 @@ describe('AntMedia Component', () => {
   });
 
   it('audio level setting test', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    }); 
+
     const { container } = render(
         <ThemeProvider theme={theme(ThemeList.Green)}>
           <AntMedia isTest={true}>
-            <MockChild/>
+            <TestMockChild/>
           </AntMedia>
         </ThemeProvider>);
 
@@ -1295,7 +1454,7 @@ describe('AntMedia Component', () => {
     const consoleSpy = jest.spyOn(console, 'error').mockImplementation();
 
     await act(async () => {
-      currentConference.setMicAudioLevel(10);
+      testConference.setMicAudioLevel(10);
     });
     expect(webRTCAdaptorConstructor.setVolumeLevel).toHaveBeenCalledWith(10);
 
@@ -1304,11 +1463,15 @@ describe('AntMedia Component', () => {
   });
 
   it('checks connection quality and displays warning for poor network connection for publish', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
 
     const { container } = render(
         <ThemeProvider theme={theme(ThemeList.Green)}>
           <AntMedia isTest={true}>
-            <MockChild/>
+            <TestMockChild/>
           </AntMedia>
         </ThemeProvider>);
 
@@ -1409,11 +1572,15 @@ describe('AntMedia Component', () => {
   });
 
   it('checks connection quality and displays warning for poor network connection for playback', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
 
     const { container } = render(
         <ThemeProvider theme={theme(ThemeList.Green)}>
           <AntMedia isTest={true}>
-            <MockChild/>
+            <TestMockChild/>
           </AntMedia>
         </ThemeProvider>);
 
@@ -1529,13 +1696,12 @@ describe('AntMedia Component', () => {
   });
 
   describe('Screen render test', () => {
-    let currentConference;
+    let testConference;
 
-    const MockChild = () => {
-      const conference = React.useContext(UnitTestContext);
-      currentConference = conference;
-      return <div>Mock Child</div>;
-    };
+    // Use the createMockChild function defined earlier to avoid the linter error
+    const TestMockChild = createMockChild(conference => {
+      testConference = conference;
+    });
 
     it('should update participantUpdated state every 5 seconds', async () => {
       jest.useFakeTimers();
@@ -1543,7 +1709,7 @@ describe('AntMedia Component', () => {
       render(
           <ThemeProvider theme={theme(ThemeList.Green)}>
             <AntMedia isTest={true}>
-              <MockChild/>
+              <TestMockChild/>
             </AntMedia>
           </ThemeProvider>
       );
@@ -1554,13 +1720,13 @@ describe('AntMedia Component', () => {
         jest.advanceTimersByTime(8000);
       });
 
-      expect(currentConference.participantUpdated).toBe(false);
+      expect(testConference.participantUpdated).toBe(true);
 
       act(() => {
         jest.advanceTimersByTime(8000);
       });
 
-      expect(currentConference.participantUpdated).toBe(false);
+      expect(testConference.participantUpdated).toBe(true);
 
       jest.useRealTimers();
     });
@@ -1571,7 +1737,7 @@ describe('AntMedia Component', () => {
       render(
           <ThemeProvider theme={theme(ThemeList.Green)}>
             <AntMedia isTest={true}>
-              <MockChild/>
+              <TestMockChild/>
             </AntMedia>
           </ThemeProvider>
       );
@@ -1582,24 +1748,29 @@ describe('AntMedia Component', () => {
         jest.advanceTimersByTime(8000);
       });
 
-      expect(currentConference.participantUpdated).toBe(false);
+      expect(testConference.participantUpdated).toBe(true);
 
       act(() => {
         jest.advanceTimersByTime(8000);
       });
 
-      expect(currentConference.participantUpdated).toBe(false);
+      expect(testConference.participantUpdated).toBe(true);
 
       jest.useRealTimers();
     });
   });
 
+  // Why there are 2 tests with the same name?
   it('fake reconnection', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
 
     const { container } = render(
         <ThemeProvider theme={theme(ThemeList.Green)}>
           <AntMedia isTest={true}>
-            <MockChild/>
+            <TestMockChild/>
           </AntMedia>
         </ThemeProvider>
     );
@@ -1698,10 +1869,14 @@ describe('AntMedia Component', () => {
   });
 
   it('fake reconnection', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
 
     const { container } = render(
         <AntMedia isTest={true}>
-          <MockChild/>
+          <TestMockChild/>
         </AntMedia>);
 
 
@@ -1709,10 +1884,10 @@ describe('AntMedia Component', () => {
       expect(webRTCAdaptorConstructor).not.toBe(undefined);
     });
 
-    expect(currentConference.isScreenShared).toBe(false);
+    expect(testConference.isScreenShared).toBe(false);
 
     await act(async () => {
-      currentConference.handleStartScreenShare();
+      testConference.handleStartScreenShare();
     });
 
     await waitFor(() => {
@@ -1725,12 +1900,12 @@ describe('AntMedia Component', () => {
 
 
     await waitFor(() => {
-      expect(currentConference.isScreenShared).toBe(true);
+      expect(testConference.isScreenShared).toBe(true);
     });
 
-    console.log(currentConference);
+    console.log(testConference);
 
-    expect(currentConference.isScreenShared).toBe(true);
+    expect(testConference.isScreenShared).toBe(true);
 
     webRTCAdaptorConstructor.reconnectIfRequired = jest.fn();
     webRTCAdaptorConstructor.requestVideoTrackAssignments = jest.fn();
@@ -1747,7 +1922,7 @@ describe('AntMedia Component', () => {
 
     await act(async () => {
       jest.useFakeTimers();
-      currentConference.fakeReconnect();
+      testConference.fakeReconnect();
       expect(webRTCAdaptorConstructor.iceConnectionState()).toBe("disconnected");
       jest.runAllTimers();
     });
@@ -1763,6 +1938,10 @@ describe('AntMedia Component', () => {
 
 
   it('checks connection quality and displays warning for poor network connection', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
 
     let stopSpeedTest = jest.fn();
     let speedTestForPlayWebRtcAdaptor = {
@@ -1777,7 +1956,7 @@ describe('AntMedia Component', () => {
     const { container } = render(
         <ThemeProvider theme={theme(ThemeList.Green)}>
           <AntMedia isTest={true}>
-            <MockChild/>
+            <TestMockChild/>
           </AntMedia>
         </ThemeProvider>);
 
@@ -1886,11 +2065,15 @@ describe('AntMedia Component', () => {
 
 
   it('should stop and nullify speedTestForPublishWebRtcAdaptor when it is defined', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
 
     const { container } = render(
         <ThemeProvider theme={theme(ThemeList.Green)}>
           <AntMedia isTest={true}>
-            <MockChild/>
+            <TestMockChild/>
           </AntMedia>
         </ThemeProvider>);
 
@@ -1899,7 +2082,7 @@ describe('AntMedia Component', () => {
     });
 
     await act(async () => {
-      currentConference.startSpeedTest();
+      testConference.startSpeedTest();
     });
 
     await waitFor(() => {
@@ -1913,7 +2096,7 @@ describe('AntMedia Component', () => {
 
     // Act
     await act(async () => {
-      currentConference.stopSpeedTest();
+      testConference.stopSpeedTest();
     });
 
     jest.useFakeTimers();
@@ -1923,7 +2106,7 @@ describe('AntMedia Component', () => {
 
     // Assert
     await waitFor(() => {
-      expect(mockStop).toHaveBeenCalledWith(`speedTestStream${currentConference.speedTestStreamId.current}`);
+      expect(mockStop).toHaveBeenCalledWith(`speedTestStream${testConference.speedTestStreamId.current}`);
     });
 
     /*
@@ -1936,6 +2119,11 @@ describe('AntMedia Component', () => {
 
 
   it('should not throw error when speedTestForPublishWebRtcAdaptor is not defined', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
+
     let stopSpeedTest = jest.fn();
     let speedTestForPlayWebRtcAdaptor = {
       current: {
@@ -1953,7 +2141,7 @@ describe('AntMedia Component', () => {
     // Act and Assert
     await expect(async () => {
       await act(async () => {
-        currentConference?.stopSpeedTest();
+        testConference?.stopSpeedTest();
       });
     }).not.toThrow();
   });
@@ -1961,11 +2149,15 @@ describe('AntMedia Component', () => {
 
 
   it('should stop and nullify speedTestForPlayWebRtcAdaptor when it is defined', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
 
     const { container } = render(
         <ThemeProvider theme={theme(ThemeList.Green)}>
           <AntMedia isTest={true}>
-            <MockChild/>
+            <TestMockChild/>
           </AntMedia>
         </ThemeProvider>);
 
@@ -1973,14 +2165,14 @@ describe('AntMedia Component', () => {
       expect(webRTCAdaptorConstructor).not.toBe(undefined);
     });
 
-    currentConference.setIsPlayOnly(true);
+    testConference.setIsPlayOnly(true);
 
     await waitFor(() => {
-      expect(currentConference.isPlayOnly).toBe(true);
+      expect(testConference.isPlayOnly).toBe(true);
     });
 
     await act(async () => {
-      currentConference.startSpeedTest();
+      testConference.startSpeedTest();
     });
 
     await waitFor(() => {
@@ -1997,7 +2189,7 @@ describe('AntMedia Component', () => {
 
     // Act
     await act(async () => {
-      currentConference.stopSpeedTest();
+      testConference.stopSpeedTest();
     });
 
     // Assert
@@ -2011,6 +2203,11 @@ describe('AntMedia Component', () => {
 
 
   it('should not throw error when speedTestForPlayWebRtcAdaptor is not defined', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
+
     let stopSpeedTest = jest.fn();
     let speedTestForPlayWebRtcAdaptor = {
       current: {
@@ -2025,16 +2222,21 @@ describe('AntMedia Component', () => {
     // Act and Assert
     await expect(async () => {
       await act(async () => {
-        currentConference?.stopSpeedTest();
+        testConference?.stopSpeedTest();
       });
     }).not.toThrow();
   });
 
   it('notSetRemoteDescription error callback in reconnection', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
+
     const { container } = render(
         <ThemeProvider theme={theme(ThemeList.Green)}>
           <AntMedia isTest={true}>
-            <MockChild/>
+            <TestMockChild/>
           </AntMedia>
         </ThemeProvider>);
 
@@ -2071,10 +2273,15 @@ describe('AntMedia Component', () => {
   });
 
   it('license_suspended_please_renew_license error callback in reconnection', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
+
     const { container } = render(
         <ThemeProvider theme={theme(ThemeList.Green)}>
           <AntMedia isTest={true}>
-            <MockChild/>
+            <TestMockChild/>
           </AntMedia>
         </ThemeProvider>);
 
@@ -2109,12 +2316,17 @@ describe('AntMedia Component', () => {
 
 
   it('increments streamIdInUseCounter and does not leave room when counter is less than or equal to 3', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
+
     const consoleSpy = jest.spyOn(console, 'log').mockImplementation();
 
     const {container} = render(
         <ThemeProvider theme={theme(ThemeList.Green)}>
           <AntMedia isTest={true}>
-            <MockChild/>
+            <TestMockChild/>
           </AntMedia>
         </ThemeProvider>);
 
@@ -2134,12 +2346,17 @@ describe('AntMedia Component', () => {
   });
 
   it('increments streamIdInUseCounter and leaves room with error when counter exceeds 3', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
+
     const consoleSpy = jest.spyOn(console, 'log').mockImplementation();
 
     const {container} = render(
         <ThemeProvider theme={theme(ThemeList.Green)}>
           <AntMedia isTest={true}>
-            <MockChild/>
+            <TestMockChild/>
           </AntMedia>
         </ThemeProvider>);
 
@@ -2161,12 +2378,17 @@ describe('AntMedia Component', () => {
   });
 
   it('streamIdInUseCounter is not incremented due to reconnection is true', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
+
     const consoleSpy = jest.spyOn(console, 'log').mockImplementation();
 
     const {container} = render(
         <ThemeProvider theme={theme(ThemeList.Green)}>
           <AntMedia isTest={true}>
-            <MockChild/>
+            <TestMockChild/>
           </AntMedia>
         </ThemeProvider>);
 
@@ -2192,10 +2414,15 @@ describe('AntMedia Component', () => {
   });
 
   it('updates allParticipants and participantUpdated when subtrackList is provided', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
+
     const { container } = render(
         <ThemeProvider theme={theme(ThemeList.Green)}>
           <AntMedia isTest={true}>
-            <MockChild/>
+            <TestMockChild/>
           </AntMedia>
         </ThemeProvider>);
 
@@ -2215,15 +2442,20 @@ describe('AntMedia Component', () => {
     });
 
     await waitFor(() => {
-      expect(currentConference.participantUpdated).toBe(false);
+      expect(testConference.participantUpdated).toBe(false);
     });
   });
 
   it('adds fake participants to allParticipants', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
+
     const { container } = render(
         <ThemeProvider theme={theme(ThemeList.Green)}>
           <AntMedia isTest={true}>
-            <MockChild/>
+            <TestMockChild/>
           </AntMedia>
         </ThemeProvider>);
 
@@ -2232,11 +2464,11 @@ describe('AntMedia Component', () => {
       expect(webRTCAdaptorConstructor).not.toBe(undefined);
     });
 
-    currentConference.allParticipants["fakeStream1"] = {streamId: 'fakeStream1', isFake: true, videoTrackId: "participant0", parsedMetaData : {isScreenShared:false}};
+    testConference.allParticipants["fakeStream1"] = {streamId: 'fakeStream1', isFake: true, videoTrackId: "participant0", parsedMetaData : {isScreenShared:false}};
 
     await waitFor(() => {
-      expect(currentConference.allParticipants["fakeStream1"]).toBeDefined();
-      expect(currentConference.allParticipants["fakeStream1"].isFake).toBe(true);
+      expect(testConference.allParticipants["fakeStream1"]).toBeDefined();
+      expect(testConference.allParticipants["fakeStream1"].isFake).toBe(true);
     });
 
     const subtrackList = [
@@ -2249,16 +2481,21 @@ describe('AntMedia Component', () => {
     });
 
     await waitFor(() => {
-      expect(currentConference.allParticipants["fakeStream1"]).toBeDefined();
-      expect(currentConference.participantUpdated).toBe(false);
+      expect(testConference.allParticipants["fakeStream1"]).toBeDefined();
+      expect(testConference.participantUpdated).toBe(false);
     });
   });
 
   it('handle the case if the metadata is empty', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
+
     const { container } = render(
         <ThemeProvider theme={theme(ThemeList.Green)}>
           <AntMedia isTest={true}>
-            <MockChild/>
+            <TestMockChild/>
           </AntMedia>
         </ThemeProvider>);
 
@@ -2278,15 +2515,20 @@ describe('AntMedia Component', () => {
     });
 
     await waitFor(() => {
-      expect(currentConference.participantUpdated).toBe(false);
+      expect(testConference.participantUpdated).toBe(false);
     });
   });
 
   it('does not update allParticipants if there are no changes', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
+
     const { container } = render(
         <ThemeProvider theme={theme(ThemeList.Green)}>
           <AntMedia isTest={true}>
-            <MockChild/>
+            <TestMockChild/>
           </AntMedia>
         </ThemeProvider>);
 
@@ -2295,7 +2537,7 @@ describe('AntMedia Component', () => {
       expect(webRTCAdaptorConstructor).not.toBe(undefined);
     });
 
-    currentConference.allParticipants = {
+    testConference.allParticipants = {
       'stream1': { streamId: 'stream1', isScreenShared: false }
     };
     const subtrackList = [
@@ -2308,15 +2550,20 @@ describe('AntMedia Component', () => {
     });
 
     await waitFor(() => {
-      expect(currentConference.participantUpdated).toBe(false);
+      expect(testConference.participantUpdated).toBe(false);
     });
   });
 
   it('sets allParticipants with "You" when not in play only mode', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
+
     const { container } = render(
         <ThemeProvider theme={theme(ThemeList.Green)}>
           <AntMedia isTest={true}>
-            <MockChild/>
+            <TestMockChild/>
           </AntMedia>
         </ThemeProvider>);
 
@@ -2325,11 +2572,11 @@ describe('AntMedia Component', () => {
       expect(webRTCAdaptorConstructor).not.toBe(undefined);
     });
 
-    currentConference.allParticipants = {
+    testConference.allParticipants = {
       'publishStreamId': { name: 'You' },
     };
 
-    currentConference.isPlayOnly = false;
+    testConference.isPlayOnly = false;
 
     const subtrackList = [
       JSON.stringify({ streamId: 'stream1', metaData: JSON.stringify({ isScreenShared: false }), receivedBytes: -1, duration: -1, bitrate: -1, updateTime: -1 })
@@ -2341,16 +2588,21 @@ describe('AntMedia Component', () => {
     });
 
     await waitFor(() => {
-      expect(currentConference.participantUpdated).toBe(false);
+      expect(testConference.participantUpdated).toBe(false);
     });
   });
 
   describe('fetchImageAsBlob', () => {
     it('returns a blob URL when the fetch is successful', async () => {
+      let testConference;
+      const TestMockChild = createMockChild(conf => {
+        testConference = conf;
+      });
+
       const { container } = render(
           <ThemeProvider theme={theme(ThemeList.Green)}>
             <AntMedia isTest={true}>
-              <MockChild/>
+              <TestMockChild/>
             </AntMedia>
           </ThemeProvider>);
 
@@ -2366,7 +2618,7 @@ describe('AntMedia Component', () => {
       });
       global.URL.createObjectURL = jest.fn().mockReturnValue(mockUrl);
 
-      const result = await currentConference.fetchImageAsBlob('http://example.com/image.png');
+      const result = await testConference.fetchImageAsBlob('http://example.com/image.png');
 
       expect(result).toBe(mockUrl);
       expect(global.fetch).toHaveBeenCalledWith('http://example.com/image.png');
@@ -2374,10 +2626,15 @@ describe('AntMedia Component', () => {
     });
 
     it('throws an error when the fetch fails', async () => {
+      let testConference;
+      const TestMockChild = createMockChild(conf => {
+        testConference = conf;
+      });
+
       const { container } = render(
           <ThemeProvider theme={theme(ThemeList.Green)}>
             <AntMedia isTest={true}>
-              <MockChild/>
+              <TestMockChild/>
             </AntMedia>
           </ThemeProvider>);
 
@@ -2388,14 +2645,19 @@ describe('AntMedia Component', () => {
 
       global.fetch = jest.fn().mockRejectedValue(new Error('Fetch failed'));
 
-      await expect(currentConference.fetchImageAsBlob('http://example.com/image.png')).rejects.toThrow('Fetch failed');
+      await expect(testConference.fetchImageAsBlob('http://example.com/image.png')).rejects.toThrow('Fetch failed');
     });
 
     it('throws an error when the blob conversion fails', async () => {
+      let testConference;
+      const TestMockChild = createMockChild(conf => {
+        testConference = conf;
+      });
+
       const { container } = render(
           <ThemeProvider theme={theme(ThemeList.Green)}>
             <AntMedia isTest={true}>
-              <MockChild/>
+              <TestMockChild/>
             </AntMedia>
           </ThemeProvider>);
 
@@ -2408,16 +2670,21 @@ describe('AntMedia Component', () => {
         blob: jest.fn().mockRejectedValue(new Error('Blob conversion failed')),
       });
 
-      await expect(currentConference.fetchImageAsBlob('http://example.com/image.png')).rejects.toThrow('Blob conversion failed');
+      await expect(testConference.fetchImageAsBlob('http://example.com/image.png')).rejects.toThrow('Blob conversion failed');
     });
   });
 
   describe('setVirtualBackgroundImage', () => {
     it('returns immediately if the URL is undefined', async () => {
+      let testConference;
+      const TestMockChild = createMockChild(conf => {
+        testConference = conf;
+      });
+
       const {container} = render(
           <ThemeProvider theme={theme(ThemeList.Green)}>
             <AntMedia isTest={true}>
-              <MockChild/>
+              <TestMockChild/>
             </AntMedia>
           </ThemeProvider>);
 
@@ -2426,15 +2693,20 @@ describe('AntMedia Component', () => {
         expect(webRTCAdaptorConstructor).not.toBe(undefined);
       });
 
-      const result = currentConference.setVirtualBackgroundImage(undefined);
+      const result = testConference.setVirtualBackgroundImage(undefined);
       expect(result).toBeUndefined();
     });
 
     it('returns immediately if the URL is null', async () => {
+      let testConference;
+      const TestMockChild = createMockChild(conf => {
+        testConference = conf;
+      });
+
       const { container } = render(
           <ThemeProvider theme={theme(ThemeList.Green)}>
             <AntMedia isTest={true}>
-              <MockChild/>
+              <TestMockChild/>
             </AntMedia>
           </ThemeProvider>);
 
@@ -2443,15 +2715,20 @@ describe('AntMedia Component', () => {
         expect(webRTCAdaptorConstructor).not.toBe(undefined);
       });
 
-      const result = currentConference.setVirtualBackgroundImage(null);
+      const result = testConference.setVirtualBackgroundImage(null);
       expect(result).toBeUndefined();
     });
 
     it('returns immediately if the URL is an empty string', async () => {
+      let testConference;
+      const TestMockChild = createMockChild(conf => {
+        testConference = conf;
+      });
+
       const { container } = render(
           <ThemeProvider theme={theme(ThemeList.Green)}>
             <AntMedia isTest={true}>
-              <MockChild/>
+              <TestMockChild/>
             </AntMedia>
           </ThemeProvider>);
 
@@ -2460,15 +2737,20 @@ describe('AntMedia Component', () => {
         expect(webRTCAdaptorConstructor).not.toBe(undefined);
       });
 
-      const result = currentConference.setVirtualBackgroundImage('');
+      const result = testConference.setVirtualBackgroundImage('');
       expect(result).toBeUndefined();
     });
 
     it('calls setAndEnableVirtualBackgroundImage if the URL starts with "data:image"', async () => {
+      let testConference;
+      const TestMockChild = createMockChild(conf => {
+        testConference = conf;
+      });
+
       const { container } = render(
           <ThemeProvider theme={theme(ThemeList.Green)}>
             <AntMedia isTest={true}>
-              <MockChild/>
+              <TestMockChild/>
             </AntMedia>
           </ThemeProvider>);
 
@@ -2478,14 +2760,19 @@ describe('AntMedia Component', () => {
       });
 
       const mockUrl = 'data:image/png;base64,example';
-      currentConference.setVirtualBackgroundImage(mockUrl);
+      testConference.setVirtualBackgroundImage(mockUrl);
     });
 
     it('fetches the image as a blob and calls setAndEnableVirtualBackgroundImage if the URL does not start with "data:image"', async () => {
+      let testConference;
+      const TestMockChild = createMockChild(conf => {
+        testConference = conf;
+      });
+
       const { container } = render(
           <ThemeProvider theme={theme(ThemeList.Green)}>
             <AntMedia isTest={true}>
-              <MockChild/>
+              <TestMockChild/>
             </AntMedia>
           </ThemeProvider>);
 
@@ -2500,18 +2787,23 @@ describe('AntMedia Component', () => {
         blob: jest.fn().mockResolvedValue(new Blob(['image content'], { type: 'image/png' })),
       });
       global.URL.createObjectURL = jest.fn().mockReturnValue(mockBlobUrl);
-      currentConference.setAndEnableVirtualBackgroundImage = jest.fn();
-      await currentConference.setVirtualBackgroundImage(mockUrl);
+      testConference.setAndEnableVirtualBackgroundImage = jest.fn();
+      await testConference.setVirtualBackgroundImage(mockUrl);
       expect(global.fetch).toHaveBeenCalledWith(mockUrl);
     });
   });
 
   describe('handleBackgroundReplacement', () => {
     it('disables video effect when option is "none"', async () => {
+      let testConference;
+      const TestMockChild = createMockChild(conf => {
+        testConference = conf;
+      });
+
       const { container } = render(
           <ThemeProvider theme={theme(ThemeList.Green)}>
             <AntMedia isTest={true}>
-              <MockChild/>
+              <TestMockChild/>
             </AntMedia>
           </ThemeProvider>);
 
@@ -2520,17 +2812,22 @@ describe('AntMedia Component', () => {
         expect(webRTCAdaptorConstructor).not.toBe(undefined);
       });
 
-      currentConference.setIsVideoEffectRunning = jest.fn();
+      testConference.setIsVideoEffectRunning = jest.fn();
 
-      currentConference.handleBackgroundReplacement("none");
-      expect(currentConference.setIsVideoEffectRunning).not.toHaveBeenCalled();
+      testConference.handleBackgroundReplacement("none");
+      expect(testConference.setIsVideoEffectRunning).not.toHaveBeenCalled();
     });
 
     it('enables slight blur effect when option is "slight-blur"', async () => {
+      let testConference;
+      const TestMockChild = createMockChild(conf => {
+        testConference = conf;
+      });
+
       const { container } = render(
           <ThemeProvider theme={theme(ThemeList.Green)}>
             <AntMedia isTest={true}>
-              <MockChild/>
+              <TestMockChild/>
             </AntMedia>
           </ThemeProvider>);
 
@@ -2539,17 +2836,22 @@ describe('AntMedia Component', () => {
         expect(webRTCAdaptorConstructor).not.toBe(undefined);
       });
 
-      currentConference.setIsVideoEffectRunning = jest.fn();
+      testConference.setIsVideoEffectRunning = jest.fn();
 
-      currentConference.handleBackgroundReplacement("slight-blur");
-      expect(currentConference.setIsVideoEffectRunning).not.toHaveBeenCalled();
+      testConference.handleBackgroundReplacement("slight-blur");
+      expect(testConference.setIsVideoEffectRunning).not.toHaveBeenCalled();
     });
 
     it('enables blur effect when option is "blur"', async () => {
+      let testConference;
+      const TestMockChild = createMockChild(conf => {
+        testConference = conf;
+      });
+
       const { container } = render(
           <ThemeProvider theme={theme(ThemeList.Green)}>
             <AntMedia isTest={true}>
-              <MockChild/>
+              <TestMockChild/>
             </AntMedia>
           </ThemeProvider>);
 
@@ -2558,17 +2860,22 @@ describe('AntMedia Component', () => {
         expect(webRTCAdaptorConstructor).not.toBe(undefined);
       });
 
-      currentConference.setIsVideoEffectRunning = jest.fn();
+      testConference.setIsVideoEffectRunning = jest.fn();
 
-      currentConference.handleBackgroundReplacement("blur");
-      expect(currentConference.setIsVideoEffectRunning).not.toHaveBeenCalled();
+      testConference.handleBackgroundReplacement("blur");
+      expect(testConference.setIsVideoEffectRunning).not.toHaveBeenCalled();
     });
 
     it('enables virtual background effect when option is "background" and virtualBackground is not null', async () => {
+      let testConference;
+      const TestMockChild = createMockChild(conf => {
+        testConference = conf;
+      });
+
       const { container } = render(
           <ThemeProvider theme={theme(ThemeList.Green)}>
             <AntMedia isTest={true}>
-              <MockChild/>
+              <TestMockChild/>
             </AntMedia>
           </ThemeProvider>);
 
@@ -2577,19 +2884,24 @@ describe('AntMedia Component', () => {
         expect(webRTCAdaptorConstructor).not.toBe(undefined);
       });
 
-      currentConference.setIsVideoEffectRunning = jest.fn();
+      testConference.setIsVideoEffectRunning = jest.fn();
 
       process.env.REACT_APP_VIRTUAL_BACKGROUND_IMAGES = "http://example.com/image.png";
 
-      currentConference.handleBackgroundReplacement("background");
-      expect(currentConference.setIsVideoEffectRunning).not.toHaveBeenCalled();
+      testConference.handleBackgroundReplacement("background");
+      expect(testConference.setIsVideoEffectRunning).not.toHaveBeenCalled();
     });
 
     it('sets and enables virtual background image when option is "background" and virtualBackground is null', async () => {
+      let testConference;
+      const TestMockChild = createMockChild(conf => {
+        testConference = conf;
+      });
+
       const { container } = render(
           <ThemeProvider theme={theme(ThemeList.Green)}>
             <AntMedia isTest={true}>
-              <MockChild/>
+              <TestMockChild/>
             </AntMedia>
           </ThemeProvider>);
 
@@ -2600,19 +2912,24 @@ describe('AntMedia Component', () => {
 
       process.env.REACT_APP_VIRTUAL_BACKGROUND_IMAGES = null;
 
-      currentConference.setAndEnableVirtualBackgroundImage = jest.fn();
+      testConference.setAndEnableVirtualBackgroundImage = jest.fn();
 
-      await currentConference.handleBackgroundReplacement("background");
+      await testConference.handleBackgroundReplacement("background");
       await waitFor(() => {
-        expect(currentConference.setAndEnableVirtualBackgroundImage).not.toHaveBeenCalled();
+        expect(testConference.setAndEnableVirtualBackgroundImage).not.toHaveBeenCalled();
       });
     });
 
     it('handles error when enabling effect fails', async () => {
+      let testConference;
+      const TestMockChild = createMockChild(conf => {
+        testConference = conf;
+      });
+
       const { container } = render(
           <ThemeProvider theme={theme(ThemeList.Green)}>
             <AntMedia isTest={true}>
-              <MockChild />
+              <TestMockChild/>
             </AntMedia>
           </ThemeProvider>
       );
@@ -2621,21 +2938,26 @@ describe('AntMedia Component', () => {
         expect(webRTCAdaptorConstructor).not.toBe(undefined);
       });
 
-      currentConference.enableEffect = jest.fn()
+      testConference.enableEffect = jest.fn()
 
-      currentConference.enableEffect.mockRejectedValue(new Error('Effect enable failed')); // Mock failure
+      testConference.enableEffect.mockRejectedValue(new Error('Effect enable failed')); // Mock failure
 
-      await currentConference.handleBackgroundReplacement("blur");
+      await testConference.handleBackgroundReplacement("blur");
     });
 
   });
 
   describe('checkAndUpdateVideoAudioSourcesForPublishSpeedTest', () => {
     it('selects the first available camera if the selected camera is not available', async () => {
+      let testConference;
+      const TestMockChild = createMockChild(conf => {
+        testConference = conf;
+      });
+
       const { container } = render(
           <ThemeProvider theme={theme(ThemeList.Green)}>
             <AntMedia isTest={true}>
-              <MockChild/>
+              <TestMockChild/>
             </AntMedia>
           </ThemeProvider>);
 
@@ -2651,20 +2973,25 @@ describe('AntMedia Component', () => {
       const mockSelectedDevices = { videoDeviceId: 'camera2', audioDeviceId: 'microphone1' };
       const mockSetSelectedDevices = jest.fn();
 
-      currentConference.devices = mockDevices;
-      currentConference.getSelectedDevices = jest.fn().mockReturnValue(mockSelectedDevices);
-      currentConference.setSelectedDevices = mockSetSelectedDevices;
+      testConference.devices = mockDevices;
+      testConference.getSelectedDevices = jest.fn().mockReturnValue(mockSelectedDevices);
+      testConference.setSelectedDevices = mockSetSelectedDevices;
 
-      currentConference.checkAndUpdateVideoAudioSourcesForPublishSpeedTest();
+      testConference.checkAndUpdateVideoAudioSourcesForPublishSpeedTest();
 
       //expect(mockSetSelectedDevices).toHaveBeenCalledWith({ videoDeviceId: 'camera1', audioDeviceId: 'microphone1' });
     });
 
     it('selects the first available microphone if the selected microphone is not available', async () => {
+      let testConference;
+      const TestMockChild = createMockChild(conf => {
+        testConference = conf;
+      });
+
       const { container } = render(
           <ThemeProvider theme={theme(ThemeList.Green)}>
             <AntMedia isTest={true}>
-              <MockChild/>
+              <TestMockChild/>
             </AntMedia>
           </ThemeProvider>);
 
@@ -2680,20 +3007,25 @@ describe('AntMedia Component', () => {
       const mockSelectedDevices = { videoDeviceId: 'camera1', audioDeviceId: 'microphone2' };
       const mockSetSelectedDevices = jest.fn();
 
-      currentConference.devices = mockDevices;
-      currentConference.getSelectedDevices = jest.fn().mockReturnValue(mockSelectedDevices);
-      currentConference.setSelectedDevices = mockSetSelectedDevices;
+      testConference.devices = mockDevices;
+      testConference.getSelectedDevices = jest.fn().mockReturnValue(mockSelectedDevices);
+      testConference.setSelectedDevices = mockSetSelectedDevices;
 
-      currentConference.checkAndUpdateVideoAudioSourcesForPublishSpeedTest();
+      testConference.checkAndUpdateVideoAudioSourcesForPublishSpeedTest();
 
       //expect(mockSetSelectedDevices).toHaveBeenCalledWith({ videoDeviceId: 'camera1', audioDeviceId: 'microphone1' });
     });
 
     it('does not change selected devices if they are available', async () => {
+      let testConference;
+      const TestMockChild = createMockChild(conf => {
+        testConference = conf;
+      });
+
       const { container } = render(
           <ThemeProvider theme={theme(ThemeList.Green)}>
             <AntMedia isTest={true}>
-              <MockChild/>
+              <TestMockChild/>
             </AntMedia>
           </ThemeProvider>);
 
@@ -2709,20 +3041,25 @@ describe('AntMedia Component', () => {
       const mockSelectedDevices = { videoDeviceId: 'camera1', audioDeviceId: 'microphone1' };
       const mockSetSelectedDevices = jest.fn();
 
-      currentConference.devices = mockDevices;
-      currentConference.getSelectedDevices = jest.fn().mockReturnValue(mockSelectedDevices);
-      currentConference.setSelectedDevices = mockSetSelectedDevices;
+      testConference.devices = mockDevices;
+      testConference.getSelectedDevices = jest.fn().mockReturnValue(mockSelectedDevices);
+      testConference.setSelectedDevices = mockSetSelectedDevices;
 
-      currentConference.checkAndUpdateVideoAudioSourcesForPublishSpeedTest();
+      testConference.checkAndUpdateVideoAudioSourcesForPublishSpeedTest();
 
       //expect(mockSetSelectedDevices).toHaveBeenCalledWith(mockSelectedDevices);
     });
 
     it('switches video camera capture if the selected camera changes', async () => {
+      let testConference;
+      const TestMockChild = createMockChild(conf => {
+        testConference = conf;
+      });
+
       const { container } = render(
           <ThemeProvider theme={theme(ThemeList.Green)}>
             <AntMedia isTest={true}>
-              <MockChild/>
+              <TestMockChild/>
             </AntMedia>
           </ThemeProvider>);
 
@@ -2735,22 +3072,27 @@ describe('AntMedia Component', () => {
       const mockSetSelectedDevices = jest.fn();
       const mockSwitchVideoCameraCapture = jest.fn();
 
-      currentConference.devices = [{ kind: 'videoinput', deviceId: 'camera1' }];
-      currentConference.getSelectedDevices = jest.fn().mockReturnValue(mockSelectedDevices);
-      currentConference.setSelectedDevices = mockSetSelectedDevices;
-      currentConference.speedTestForPublishWebRtcAdaptor = { current: { switchVideoCameraCapture: mockSwitchVideoCameraCapture } };
-      currentConference.publishStreamId = 'stream1';
+      testConference.devices = [{ kind: 'videoinput', deviceId: 'camera1' }];
+      testConference.getSelectedDevices = jest.fn().mockReturnValue(mockSelectedDevices);
+      testConference.setSelectedDevices = mockSetSelectedDevices;
+      testConference.speedTestForPublishWebRtcAdaptor = { current: { switchVideoCameraCapture: mockSwitchVideoCameraCapture } };
+      testConference.publishStreamId = 'stream1';
 
-      currentConference.checkAndUpdateVideoAudioSourcesForPublishSpeedTest();
+      testConference.checkAndUpdateVideoAudioSourcesForPublishSpeedTest();
 
       //expect(mockSwitchVideoCameraCapture).toHaveBeenCalledWith('stream1', 'camera1');
     });
 
     it('switches audio input source if the selected microphone changes', async () => {
+      let testConference;
+      const TestMockChild = createMockChild(conf => {
+        testConference = conf;
+      });
+
       const { container } = render(
           <ThemeProvider theme={theme(ThemeList.Green)}>
             <AntMedia isTest={true}>
-              <MockChild/>
+              <TestMockChild/>
             </AntMedia>
           </ThemeProvider>);
 
@@ -2763,22 +3105,27 @@ describe('AntMedia Component', () => {
       const mockSetSelectedDevices = jest.fn();
       const mockSwitchAudioInputSource = jest.fn();
 
-      currentConference.devices = [{ kind: 'audioinput', deviceId: 'microphone1' }];
-      currentConference.getSelectedDevices = jest.fn().mockReturnValue(mockSelectedDevices);
-      currentConference.setSelectedDevices = mockSetSelectedDevices;
-      currentConference.speedTestForPublishWebRtcAdaptor = { current: { switchAudioInputSource: mockSwitchAudioInputSource } };
-      currentConference.publishStreamId = 'stream1';
+      testConference.devices = [{ kind: 'audioinput', deviceId: 'microphone1' }];
+      testConference.getSelectedDevices = jest.fn().mockReturnValue(mockSelectedDevices);
+      testConference.setSelectedDevices = mockSetSelectedDevices;
+      testConference.speedTestForPublishWebRtcAdaptor = { current: { switchAudioInputSource: mockSwitchAudioInputSource } };
+      testConference.publishStreamId = 'stream1';
 
-      currentConference.checkAndUpdateVideoAudioSourcesForPublishSpeedTest();
+      testConference.checkAndUpdateVideoAudioSourcesForPublishSpeedTest();
 
       //expect(mockSwitchAudioInputSource).toHaveBeenCalledWith('stream1', 'microphone1');
     });
 
     it('handles errors when switching video and audio sources', async () => {
+      let testConference;
+      const TestMockChild = createMockChild(conf => {
+        testConference = conf;
+      });
+
       const { container } = render(
           <ThemeProvider theme={theme(ThemeList.Green)}>
             <AntMedia isTest={true}>
-              <MockChild/>
+              <TestMockChild/>
             </AntMedia>
           </ThemeProvider>);
 
@@ -2793,18 +3140,23 @@ describe('AntMedia Component', () => {
       const mockSwitchAudioInputSource = jest.fn().mockImplementation(() => { throw new Error('Error switching audio'); });
       const mockConsoleError = jest.spyOn(console, 'error').mockImplementation();
 
-      currentConference.devices = [{ kind: 'videoinput', deviceId: 'camera1' }, { kind: 'audioinput', deviceId: 'microphone1' }];
-      currentConference.getSelectedDevices = jest.fn().mockReturnValue(mockSelectedDevices);
-      currentConference.setSelectedDevices = mockSetSelectedDevices;
-      currentConference.speedTestForPublishWebRtcAdaptor = { current: { switchVideoCameraCapture: mockSwitchVideoCameraCapture, switchAudioInputSource: mockSwitchAudioInputSource } };
-      currentConference.publishStreamId = 'stream1';
+      testConference.devices = [{ kind: 'videoinput', deviceId: 'camera1' }, { kind: 'audioinput', deviceId: 'microphone1' }];
+      testConference.getSelectedDevices = jest.fn().mockReturnValue(mockSelectedDevices);
+      testConference.setSelectedDevices = mockSetSelectedDevices;
+      testConference.speedTestForPublishWebRtcAdaptor = { current: { switchVideoCameraCapture: mockSwitchVideoCameraCapture, switchAudioInputSource: mockSwitchAudioInputSource } };
+      testConference.publishStreamId = 'stream1';
 
-      currentConference.checkAndUpdateVideoAudioSourcesForPublishSpeedTest();
+      testConference.checkAndUpdateVideoAudioSourcesForPublishSpeedTest();
 
       //expect(mockConsoleError).toHaveBeenCalledWith('Error while switching video and audio sources for the publish speed test adaptor', expect.any(Error));
     });
 
     it('handles errors when switching video and audio source', async () => {
+      let testConference;
+      const TestMockChild = createMockChild(conf => {
+        testConference = conf;
+      });
+
       mediaDevicesMock.enumerateDevices.mockResolvedValue([
         { deviceId: 'camera1', kind: 'videoinput' },
         { deviceId: 'microphone1', kind: 'audioinput' }
@@ -2813,7 +3165,7 @@ describe('AntMedia Component', () => {
       const {container} = render(
           <ThemeProvider theme={theme(ThemeList.Green)}>
             <AntMedia isTest={true}>
-              <MockChild/>
+              <TestMockChild/>
             </AntMedia>
           </ThemeProvider>);
 
@@ -2822,7 +3174,7 @@ describe('AntMedia Component', () => {
       });
 
       await act(async () => {
-        currentConference.startSpeedTest();
+        testConference.startSpeedTest();
       });
 
       await waitFor(() => {
@@ -2846,15 +3198,15 @@ describe('AntMedia Component', () => {
       });
       const mockConsoleError = jest.spyOn(console, 'error').mockImplementation();
 
-      currentConference.devices = [{kind: 'videoinput', deviceId: 'camera1'}, {kind: 'audioinput', deviceId: 'microphone1'}];
-      currentConference.getSelectedDevices = jest.fn().mockReturnValue(mockSelectedDevices);
-      currentConference.setSelectedDevices = mockSetSelectedDevices;
-      currentConference.speedTestForPublishWebRtcAdaptor = {current: {switchVideoCameraCapture: mockSwitchVideoCameraCapture, switchAudioInputSource: mockSwitchAudioInputSource}};
-      currentConference.switchVideoCameraCapture = mockSwitchVideoCameraCapture;
-      currentConference.publishStreamId = 'stream1';
+      testConference.devices = [{kind: 'videoinput', deviceId: 'camera1'}, {kind: 'audioinput', deviceId: 'microphone1'}];
+      testConference.getSelectedDevices = jest.fn().mockReturnValue(mockSelectedDevices);
+      testConference.setSelectedDevices = mockSetSelectedDevices;
+      testConference.speedTestForPublishWebRtcAdaptor = {current: {switchVideoCameraCapture: mockSwitchVideoCameraCapture, switchAudioInputSource: mockSwitchAudioInputSource}};
+      testConference.switchVideoCameraCapture = mockSwitchVideoCameraCapture;
+      testConference.publishStreamId = 'stream1';
 
       await act(async () => {
-        currentConference.checkAndUpdateVideoAudioSourcesForPublishSpeedTest();
+        testConference.checkAndUpdateVideoAudioSourcesForPublishSpeedTest();
       });
       mockConsoleError.mockRestore();
     });
@@ -2862,10 +3214,15 @@ describe('AntMedia Component', () => {
 
   describe('checkVideoTrackHealth', () => {
     it('returns true if the camera is turned off by the user', async () => {
+      let testConference;
+      const TestMockChild = createMockChild(conf => {
+        testConference = conf;
+      });
+
       render(
           <ThemeProvider theme={theme(ThemeList.Green)}>
             <AntMedia isTest={true}>
-              <MockChild/>
+              <TestMockChild/>
             </AntMedia>
           </ThemeProvider>);
 
@@ -2874,11 +3231,11 @@ describe('AntMedia Component', () => {
         expect(webRTCAdaptorConstructor).not.toBe(undefined);
       });
 
-      currentConference.setIsMyCamTurnedOff(true);
+      testConference.setIsMyCamTurnedOff(true);
       await waitFor(() => {
-        expect(currentConference.isMyCamTurnedOff).toBe(true);
+        expect(testConference.isMyCamTurnedOff).toBe(true);
       });
-      currentConference.mediaManager = {
+      testConference.mediaManager = {
         localStream: {
           getAudioTracks: jest.fn().mockReturnValue([]),
           getVideoTracks: jest.fn().mockReturnValue([
@@ -2886,14 +3243,19 @@ describe('AntMedia Component', () => {
           ]),
         }
       };
-      expect(currentConference.checkVideoTrackHealth()).toBe(true);
+      expect(testConference.checkVideoTrackHealth()).toBe(true);
     });
 
     it('returns false if the camera is turned on and the video track is not muted', async () => {
+      let testConference;
+      const TestMockChild = createMockChild(conf => {
+        testConference = conf;
+      });
+
       render(
           <ThemeProvider theme={theme(ThemeList.Green)}>
             <AntMedia isTest={true}>
-              <MockChild/>
+              <TestMockChild/>
             </AntMedia>
           </ThemeProvider>);
 
@@ -2902,12 +3264,12 @@ describe('AntMedia Component', () => {
         expect(webRTCAdaptorConstructor).not.toBe(undefined);
       });
 
-      currentConference.setIsMyCamTurnedOff(false);
+      testConference.setIsMyCamTurnedOff(false);
       await waitFor(() => {
-        expect(currentConference.isMyCamTurnedOff).toBe(false);
+        expect(testConference.isMyCamTurnedOff).toBe(false);
       });      
 
-      currentConference.mediaManager = {
+      testConference.mediaManager = {
         localStream: {
           getAudioTracks: jest.fn().mockReturnValue([]),
           getVideoTracks: jest.fn().mockReturnValue([
@@ -2915,11 +3277,16 @@ describe('AntMedia Component', () => {
           ]),
         }
       };
-      expect(currentConference.checkVideoTrackHealth()).toBe(false);
+      expect(testConference.checkVideoTrackHealth()).toBe(false);
     });
   });
 
   it('sets and fills play stats list correctly', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
+
     const mockStats = {
       currentRoundTripTime: 100,
       packetsReceived: 200,
@@ -2936,7 +3303,7 @@ describe('AntMedia Component', () => {
     const {container} = render(
         <ThemeProvider theme={theme(ThemeList.Green)}>
           <AntMedia isTest={true}>
-            <MockChild/>
+            <TestMockChild/>
           </AntMedia>
         </ThemeProvider>);
 
@@ -2945,22 +3312,27 @@ describe('AntMedia Component', () => {
     });
 
     await act(async () => {
-      currentConference.setAndFillPlayStatsList(mockStats);
-    });
-
-    expect(currentConference.statsList.current.currentRoundTripTime).not.toBe(100);
-    expect(currentConference.statsList.current.packetsReceived).not.toBe(200);
-    expect(currentConference.statsList.current.totalBytesReceivedCount).not.toBe(300);
-    expect(currentConference.statsList.current.framesReceived).not.toBe(400);
-    expect(currentConference.statsList.current.framesDropped).not.toBe(500);
-    expect(currentConference.statsList.current.startTime).not.toBe(600);
-    expect(currentConference.statsList.current.currentTimestamp).not.toBe(700);
-    expect(currentConference.statsList.current.firstBytesReceivedCount).not.toBe(800);
-    expect(currentConference.statsList.current.lastBytesReceived).not.toBe(900);
-    expect(currentConference.statsList.current.videoPacketsLost).not.toBe(1000);
+      testConference.setAndFillPlayStatsList(mockStats);
+    });
+
+    expect(testConference.statsList.current.currentRoundTripTime).not.toBe(100);
+    expect(testConference.statsList.current.packetsReceived).not.toBe(200);
+    expect(testConference.statsList.current.totalBytesReceivedCount).not.toBe(300);
+    expect(testConference.statsList.current.framesReceived).not.toBe(400);
+    expect(testConference.statsList.current.framesDropped).not.toBe(500);
+    expect(testConference.statsList.current.startTime).not.toBe(600);
+    expect(testConference.statsList.current.currentTimestamp).not.toBe(700);
+    expect(testConference.statsList.current.firstBytesReceivedCount).not.toBe(800);
+    expect(testConference.statsList.current.lastBytesReceived).not.toBe(900);
+    expect(testConference.statsList.current.videoPacketsLost).not.toBe(1000);
   });
 
   it('sets and fills publish stats list correctly', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
+
     const mockStats = {
       videoRoundTripTime: 100,
       audioRoundTripTime: 200,
@@ -2976,7 +3348,7 @@ describe('AntMedia Component', () => {
     const {container} = render(
         <ThemeProvider theme={theme(ThemeList.Green)}>
           <AntMedia isTest={true}>
-            <MockChild/>
+            <TestMockChild/>
           </AntMedia>
         </ThemeProvider>);
 
@@ -2985,27 +3357,33 @@ describe('AntMedia Component', () => {
     });
 
     await act(async () => {
-      currentConference.setAndFillPublishStatsList(mockStats);
+      testConference.setAndFillPublishStatsList(mockStats);
     });
 
     await waitFor(() => {
-      expect(currentConference.statsList.current.videoRoundTripTime).not.toBe(100);
-      expect(currentConference.statsList.current.audioRoundTripTime).not.toBe(200);
-      expect(currentConference.statsList.current.videoPacketsLost).not.toBe(300);
-      expect(currentConference.statsList.current.totalVideoPacketsSent).not.toBe(400);
-      expect(currentConference.statsList.current.totalAudioPacketsSent).not.toBe(500);
-      expect(currentConference.statsList.current.audioPacketsLost).not.toBe(600);
-      expect(currentConference.statsList.current.videoJitter).not.toBe(700);
-      expect(currentConference.statsList.current.audioJitter).not.toBe(800);
-      expect(currentConference.statsList.current.currentOutgoingBitrate).not.toBe(900);
+      expect(testConference.statsList.current.videoRoundTripTime).not.toBe(100);
+      expect(testConference.statsList.current.audioRoundTripTime).not.toBe(200);
+      expect(testConference.statsList.current.videoPacketsLost).not.toBe(300);
+      expect(testConference.statsList.current.totalVideoPacketsSent).not.toBe(400);
+      expect(testConference.statsList.current.totalAudioPacketsSent).not.toBe(500);
+      expect(testConference.statsList.current.audioPacketsLost).not.toBe(600);
+      expect(testConference.statsList.current.videoJitter).not.toBe(700);
+      expect(testConference.statsList.current.audioJitter).not.toBe(800);
+      expect(testConference.statsList.current.currentOutgoingBitrate).not.toBe(900);
     });
   });
 
   it('sets speed test object to failed state', async () => {
+    // Create a local reference for this test
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
+    
     const {container} = render(
         <ThemeProvider theme={theme(ThemeList.Green)}>
           <AntMedia isTest={true}>
-            <MockChild/>
+            <TestMockChild/>
           </AntMedia>
         </ThemeProvider>);
 
@@ -3013,24 +3391,39 @@ describe('AntMedia Component', () => {
       expect(webRTCAdaptorConstructor).not.toBe(undefined);
     });
 
+    testConference.speedTestObject = {
+      message: "Speed Test",
+      isfinished: false,
+      isfailed: false,
+      errorMessage: "",
+      progressValue: 50
+    };
+
+    testConference.setSpeedTestObject = jest.fn();
+
     await act(async () => {
-      currentConference.setSpeedTestObjectFailed('Error message');
+      testConference.setSpeedTestObjectFailed('Error message');
     });
 
     await waitFor(() => {
-      expect(currentConference.speedTestObject.message).toBe('Error message');
-      expect(currentConference.speedTestObject.isfinished).toBe(false);
-      expect(currentConference.speedTestObject.isfailed).toBe(true);
-      expect(currentConference.speedTestObject.errorMessage).toBe('Error message');
-      expect(currentConference.speedTestObject.progressValue).toBe(0);
+      expect(testConference.speedTestObject.message).toBe('Error message');
+      expect(testConference.speedTestObject.isfinished).toBe(false);
+      expect(testConference.speedTestObject.isfailed).toBe(true);
+      expect(testConference.speedTestObject.errorMessage).toBe('Error message');
+      expect(testConference.speedTestObject.progressValue).toBe(0);
     });
   });
 
   it('sets speed test object progress correctly', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
+
     const {container} = render(
         <ThemeProvider theme={theme(ThemeList.Green)}>
           <AntMedia isTest={true}>
-            <MockChild/>
+            <TestMockChild/>
           </AntMedia>
         </ThemeProvider>);
 
@@ -3039,22 +3432,27 @@ describe('AntMedia Component', () => {
     });
 
     await act(async () => {
-      currentConference.setSpeedTestObjectProgress(50);
+      testConference.setSpeedTestObjectProgress(50);
     });
 
     await waitFor(() => {
-      expect(currentConference.speedTestObject.isfinished).toBe(false);
-      expect(currentConference.speedTestObject.isfailed).toBe(false);
-      expect(currentConference.speedTestObject.errorMessage).toBe('');
-      expect(currentConference.speedTestObject.progressValue).toBe(50);
+      expect(testConference.speedTestObject.isfinished).toBe(false);
+      expect(testConference.speedTestObject.isfailed).toBe(false);
+      expect(testConference.speedTestObject.errorMessage).toBe('');
+      expect(testConference.speedTestObject.progressValue).toBe(50);
     });
   });
 
   it('handles progress value greater than 100', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
+
     const {container} = render(
         <ThemeProvider theme={theme(ThemeList.Green)}>
           <AntMedia isTest={true}>
-            <MockChild/>
+            <TestMockChild/>
           </AntMedia>
         </ThemeProvider>);
 
@@ -3063,23 +3461,28 @@ describe('AntMedia Component', () => {
     });
 
     await act(async () => {
-      currentConference.setSpeedTestObjectProgress(150);
+      testConference.setSpeedTestObjectProgress(150);
     });
 
     const stopSpeedTest = jest.fn();
     //expect(stopSpeedTest).toHaveBeenCalled();
-    expect(currentConference.speedTestObject.message).toBe('Speed test failed. It may be due to firewall, wi-fi or network restrictions. Change your network or Try again ');
-    expect(currentConference.speedTestObject.isfinished).toBe(false);
-    expect(currentConference.speedTestObject.isfailed).toBe(true);
-    expect(currentConference.speedTestObject.errorMessage).toBe('Speed test failed. It may be due to firewall, wi-fi or network restrictions. Change your network or Try again ');
-    expect(currentConference.speedTestObject.progressValue).toBe(0);
+    expect(testConference.speedTestObject.message).toBe('Speed test failed. It may be due to firewall, wi-fi or network restrictions. Change your network or Try again ');
+    expect(testConference.speedTestObject.isfinished).toBe(false);
+    expect(testConference.speedTestObject.isfailed).toBe(true);
+    expect(testConference.speedTestObject.errorMessage).toBe('Speed test failed. It may be due to firewall, wi-fi or network restrictions. Change your network or Try again ');
+    expect(testConference.speedTestObject.progressValue).toBe(0);
   });
 
   it('calculates play speed test result with great connection', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
+
     const {container} = render(
         <ThemeProvider theme={theme(ThemeList.Green)}>
           <AntMedia isTest={true}>
-            <MockChild/>
+            <TestMockChild/>
           </AntMedia>
         </ThemeProvider>);
 
@@ -3087,7 +3490,7 @@ describe('AntMedia Component', () => {
       expect(webRTCAdaptorConstructor).not.toBe(undefined);
     });
 
-    currentConference.statsList.current = [
+    testConference.statsList.current = [
       {
         totalBytesReceivedCount: 1000,
         framesReceived: 100,
@@ -3127,20 +3530,25 @@ describe('AntMedia Component', () => {
     ];
 
     await act(async () => {
-      currentConference.calculateThePlaySpeedTestResult();
+      testConference.calculateThePlaySpeedTestResult();
     });
 
-    expect(currentConference.speedTestObject.message).toBe('Your connection is Great!');
-    expect(currentConference.speedTestObject.isfailed).toBe(false);
-    expect(currentConference.speedTestObject.progressValue).toBe(100);
-    expect(currentConference.speedTestObject.isfinished).toBe(true);
+    expect(testConference.speedTestObject.message).toBe('Your connection is Great!');
+    expect(testConference.speedTestObject.isfailed).toBe(false);
+    expect(testConference.speedTestObject.progressValue).toBe(100);
+    expect(testConference.speedTestObject.isfinished).toBe(true);
   });
 
   it('calculates play speed test result with moderate connection', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
+
     const {container} = render(
         <ThemeProvider theme={theme(ThemeList.Green)}>
           <AntMedia isTest={true}>
-            <MockChild/>
+            <TestMockChild/>
           </AntMedia>
         </ThemeProvider>);
 
@@ -3148,7 +3556,7 @@ describe('AntMedia Component', () => {
       expect(webRTCAdaptorConstructor).not.toBe(undefined);
     });
 
-    currentConference.statsList.current = [
+    testConference.statsList.current = [
       {
         totalBytesReceivedCount: 1000,
         framesReceived: 100,
@@ -3188,20 +3596,25 @@ describe('AntMedia Component', () => {
     ];
 
     await act(async () => {
-      currentConference.calculateThePlaySpeedTestResult();
+      testConference.calculateThePlaySpeedTestResult();
     });
 
-    expect(currentConference.speedTestObject.message).toBe('Your connection is moderate, occasional disruptions may occur');
-    expect(currentConference.speedTestObject.isfailed).toBe(false);
-    expect(currentConference.speedTestObject.progressValue).toBe(100);
-    expect(currentConference.speedTestObject.isfinished).toBe(true);
+    expect(testConference.speedTestObject.message).toBe('Your connection is moderate, occasional disruptions may occur');
+    expect(testConference.speedTestObject.isfailed).toBe(false);
+    expect(testConference.speedTestObject.progressValue).toBe(100);
+    expect(testConference.speedTestObject.isfinished).toBe(true);
   });
 
   it('calculates play speed test result with poor connection', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
+
     const {container} = render(
         <ThemeProvider theme={theme(ThemeList.Green)}>
           <AntMedia isTest={true}>
-            <MockChild/>
+            <TestMockChild/>
           </AntMedia>
         </ThemeProvider>);
 
@@ -3209,7 +3622,7 @@ describe('AntMedia Component', () => {
       expect(webRTCAdaptorConstructor).not.toBe(undefined);
     });
 
-    currentConference.statsList.current = [
+    testConference.statsList.current = [
       {
         totalBytesReceivedCount: 1000,
         framesReceived: 100,
@@ -3249,20 +3662,25 @@ describe('AntMedia Component', () => {
     ];
 
     await act(async () => {
-      currentConference.calculateThePlaySpeedTestResult();
+      testConference.calculateThePlaySpeedTestResult();
     });
 
-    expect(currentConference.speedTestObject.message).toBe('Your connection quality is poor. You may experience interruptions');
-    expect(currentConference.speedTestObject.isfailed).toBe(false);
-    expect(currentConference.speedTestObject.progressValue).toBe(100);
-    expect(currentConference.speedTestObject.isfinished).toBe(true);
+    expect(testConference.speedTestObject.message).toBe('Your connection quality is poor. You may experience interruptions');
+    expect(testConference.speedTestObject.isfailed).toBe(false);
+    expect(testConference.speedTestObject.progressValue).toBe(100);
+    expect(testConference.speedTestObject.isfinished).toBe(true);
   });
 
   it('updates progress and stats list on subsequent iterations', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
+
     const {container} = render(
         <ThemeProvider theme={theme(ThemeList.Green)}>
           <AntMedia isTest={true}>
-            <MockChild/>
+            <TestMockChild/>
           </AntMedia>
         </ThemeProvider>);
 
@@ -3270,22 +3688,28 @@ describe('AntMedia Component', () => {
       expect(webRTCAdaptorConstructor).not.toBe(undefined);
     });
 
-    currentConference.speedTestCounter.current = 1;
-    currentConference.statsList.current = [{}, {}];
-    currentConference.setAndFillPlayStatsList = jest.fn();
-    currentConference.setSpeedTestObjectProgress = jest.fn();
-    currentConference.setSpeedTestObject = jest.fn();
+    testConference.speedTestCounter.current = 1;
+    testConference.statsList.current = [{}, {}];
+    testConference.setAndFillPlayStatsList = jest.fn();
+    testConference.setSpeedTestObjectProgress = jest.fn();
+    testConference.setSpeedTestObject = jest.fn();
 
-    currentConference.processUpdatedStatsForPlaySpeedTest({});
+    testConference.processUpdatedStatsForPlaySpeedTest({});
 
-    expect(currentConference.statsList.current).toEqual([{}, {}, {}]);
+    expect(testConference.statsList.current).toEqual([{}, {}, {}]);
   });
 
   it('updates speed test object progress when iterations are insufficient', async () => {
+    // Create a local reference for this test
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
+    
     const {container} = render(
         <ThemeProvider theme={theme(ThemeList.Green)}>
           <AntMedia isTest={true}>
-            <MockChild/>
+            <TestMockChild/>
           </AntMedia>
         </ThemeProvider>);
 
@@ -3293,15 +3717,22 @@ describe('AntMedia Component', () => {
       expect(webRTCAdaptorConstructor).not.toBe(undefined);
     });
 
-    currentConference.speedTestCounter.current = 2;
-    currentConference.statsList.current = [{}, {}];
-    currentConference.setSpeedTestObjectProgress = jest.fn();
-    currentConference.setSpeedTestObject = jest.fn();
+    testConference.speedTestCounter = { current: 2 };
+    testConference.statsList = { current: [{}, {}] };
+    testConference.setSpeedTestObjectProgress = jest.fn();
+    testConference.setSpeedTestObject = jest.fn();
+    testConference.speedTestObject = {
+      message: "Speed Test",
+      isfinished: false,
+      isfailed: false,
+      errorMessage: "",
+      progressValue: 0
+    };
 
-    currentConference.processUpdatedStatsForPlaySpeedTest({});
+    testConference.processUpdatedStatsForPlaySpeedTest({});
 
-    expect(currentConference.setSpeedTestObject).not.toHaveBeenCalledWith({
-      message: currentConference.speedTestObject.message,
+    expect(testConference.setSpeedTestObject).not.toHaveBeenCalledWith({
+      message: testConference.speedTestObject.message,
       isfinished: false,
       isfailed: false,
       errorMessage: "",
@@ -3311,10 +3742,16 @@ describe('AntMedia Component', () => {
 
   describe('loadMoreParticipants', () => {
     it('get subtracks as many as loadingStepSize', async () => {
+      // Create a local reference for this test
+      let testConference;
+      const TestMockChild = createMockChild(conf => {
+        testConference = conf;
+      });
+      
       const { container } = render(
           <ThemeProvider theme={theme(ThemeList.Green)}>
             <AntMedia isTest={true}>
-              <MockChild/>
+              <TestMockChild/>
             </AntMedia>
           </ThemeProvider>);
 
@@ -3324,25 +3761,30 @@ describe('AntMedia Component', () => {
       });
 
       await act(async () => {
-        currentConference.globals.participantListPagination.currentPagePosition = 2;
-        currentConference.setParticipantCount(15);
+        testConference.globals.participantListPagination.currentPagePosition = 2;
+        testConference.setParticipantCount(15);
       });
 
       await waitFor(() => {
-        expect(currentConference.participantCount).toBe(15);
+        expect(testConference.participantCount).toBe(15);
       });
       
-      currentConference.loadMoreParticipants();
+      testConference.loadMoreParticipants();
 
-      expect(webRTCAdaptorConstructor.getSubtracks).toHaveBeenCalledWith("room", null, 2, currentConference.globals.participantListPagination.loadingStepSize);
+      expect(webRTCAdaptorConstructor.getSubtracks).toHaveBeenCalledWith("room", null, 2, testConference.globals.participantListPagination.loadingStepSize);
     });
 
 
     it('get subtracks as many as difference', async () => {
+      let testConference;
+      const TestMockChild = createMockChild(conf => {
+        testConference = conf;
+      });
+
       const { container } = render(
           <ThemeProvider theme={theme(ThemeList.Green)}>
             <AntMedia isTest={true}>
-              <MockChild/>
+              <TestMockChild/>
             </AntMedia>
           </ThemeProvider>);
 
@@ -3352,15 +3794,15 @@ describe('AntMedia Component', () => {
       });
 
       await act(async () => {
-        currentConference.globals.participantListPagination.currentPagePosition = 2;
-        currentConference.setParticipantCount(5);
+        testConference.globals.participantListPagination.currentPagePosition = 2;
+        testConference.setParticipantCount(5);
       });
 
       await waitFor(() => {
-        expect(currentConference.participantCount).toBe(5);
+        expect(testConference.participantCount).toBe(5);
       });
       
-      currentConference.loadMoreParticipants();
+      testConference.loadMoreParticipants();
 
       expect(webRTCAdaptorConstructor.getSubtracks).toHaveBeenCalledWith("room", null, 2, 3);
     });
@@ -3368,10 +3810,15 @@ describe('AntMedia Component', () => {
     
 
     it('update participant count, when we receive new subtrack count', async () => {
+      let testConference;
+      const TestMockChild = createMockChild(conf => {
+        testConference = conf;
+      });
+
       const { container } = render(
           <ThemeProvider theme={theme(ThemeList.Green)}>
             <AntMedia isTest={true}>
-              <MockChild/>
+              <TestMockChild/>
             </AntMedia>
           </ThemeProvider>);
 
@@ -3387,16 +3834,21 @@ describe('AntMedia Component', () => {
       });
 
       await waitFor(() => {
-        expect(currentConference.participantCount).toBe(12);
+        expect(testConference.participantCount).toBe(12);
       });
     });
   });
 
   it('opens publisher request list drawer and closes other drawers', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
+
     const {container} = render(
         <ThemeProvider theme={theme(ThemeList.Green)}>
           <AntMedia isTest={true}>
-            <MockChild/>
+            <TestMockChild/>
           </AntMedia>
         </ThemeProvider>);
 
@@ -3404,23 +3856,28 @@ describe('AntMedia Component', () => {
       expect(webRTCAdaptorConstructor).not.toBe(undefined);
     });
 
-    currentConference.setPublisherRequestListDrawerOpen = jest.fn();
-    currentConference.setMessageDrawerOpen = jest.fn();
-    currentConference.setParticipantListDrawerOpen = jest.fn();
-    currentConference.setEffectsDrawerOpen = jest.fn();
+    testConference.setPublisherRequestListDrawerOpen = jest.fn();
+    testConference.setMessageDrawerOpen = jest.fn();
+    testConference.setParticipantListDrawerOpen = jest.fn();
+    testConference.setEffectsDrawerOpen = jest.fn();
 
-    currentConference.handlePublisherRequestListOpen(true);
-    expect(currentConference.setPublisherRequestListDrawerOpen).not.toHaveBeenCalledWith(true);
-    expect(currentConference.setMessageDrawerOpen).not.toHaveBeenCalledWith(false);
-    expect(currentConference.setParticipantListDrawerOpen).not.toHaveBeenCalledWith(false);
-    expect(currentConference.setEffectsDrawerOpen).not.toHaveBeenCalledWith(false);
+    testConference.handlePublisherRequestListOpen(true);
+    expect(testConference.setPublisherRequestListDrawerOpen).not.toHaveBeenCalledWith(true);
+    expect(testConference.setMessageDrawerOpen).not.toHaveBeenCalledWith(false);
+    expect(testConference.setParticipantListDrawerOpen).not.toHaveBeenCalledWith(false);
+    expect(testConference.setEffectsDrawerOpen).not.toHaveBeenCalledWith(false);
   });
 
   it('does not send publisher request if not in play only mode', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
+
     const {container} = render(
         <ThemeProvider theme={theme(ThemeList.Green)}>
           <AntMedia isTest={true}>
-            <MockChild/>
+            <TestMockChild/>
           </AntMedia>
         </ThemeProvider>);
 
@@ -3428,19 +3885,24 @@ describe('AntMedia Component', () => {
       expect(webRTCAdaptorConstructor).not.toBe(undefined);
     });
 
-    currentConference.handleSendNotificationEvent = jest.fn();
+    testConference.handleSendNotificationEvent = jest.fn();
     await act(async () => {
-      currentConference.setIsPlayOnly(false);
+      testConference.setIsPlayOnly(false);
     });
-    currentConference.handlePublisherRequest();
-    expect(currentConference.handleSendNotificationEvent).not.toHaveBeenCalled();
+    testConference.handlePublisherRequest();
+    expect(testConference.handleSendNotificationEvent).not.toHaveBeenCalled();
   });
 
   it('sends publisher request if in play only mode', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
+
     const {container} = render(
         <ThemeProvider theme={theme(ThemeList.Green)}>
           <AntMedia isTest={true}>
-            <MockChild/>
+            <TestMockChild/>
           </AntMedia>
         </ThemeProvider>);
 
@@ -3450,10 +3912,10 @@ describe('AntMedia Component', () => {
 
 
     await act(async () => {
-      currentConference.handleSendNotificationEvent = jest.fn();
-      currentConference.setIsPlayOnly(true);
+      testConference.handleSendNotificationEvent = jest.fn();
+      testConference.setIsPlayOnly(true);
     });
-    currentConference.handlePublisherRequest();
+    testConference.handlePublisherRequest();
   });
 
   /*
@@ -3477,10 +3939,15 @@ describe('AntMedia Component', () => {
    */
 
   it('should not run playOnly effect on initial mount', async () => {
-    const { container } = render(
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
+
+      const { container } = render(
         <ThemeProvider theme={theme(ThemeList.Green)}>
             <AntMedia isTest={true}>
-                <MockChild/>
+                <TestMockChild/>
             </AntMedia>
         </ThemeProvider>
     );
@@ -3496,6 +3963,10 @@ describe('AntMedia Component', () => {
 });
 
   it('should run playOnly effect when isPlayOnly changes after mount', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
 
     const mockLocalStorage = {
       getItem: jest.fn().mockImplementation((key) => {
@@ -3515,7 +3986,7 @@ describe('AntMedia Component', () => {
     const { render1 } = render(
         <ThemeProvider theme={theme(ThemeList.Green)}>
             <AntMedia isTest={true} isPlayOnly={false}>
-                <MockChild/>
+                <TestMockChild/>
             </AntMedia>
         </ThemeProvider>
     );
@@ -3525,24 +3996,27 @@ describe('AntMedia Component', () => {
     });
 
     await act(async () => {
-      currentConference.setIsPlayOnly(true);
+      testConference.setIsPlayOnly(true);
     });
 
     await waitFor(() => {
-      console.log('Initadasdasdasdad:', createdAdaptors.main.length);
 
-      //We need to check the old adaptor's methods to be able to test this effect because old adaptor is being stopped and new one will be created. However our initialization is done and timing is not working if we try to test directly webrtcAdaptorConstructor here.
-      expect(oldAdaptor.stop).toHaveBeenCalled();
-      expect(oldAdaptor.turnOffLocalCamera).toHaveBeenCalled();
-      expect(oldAdaptor.closeStream).toHaveBeenCalled();
+      expect(webRTCAdaptorConstructor.stop).toHaveBeenCalled();
+      expect(webRTCAdaptorConstructor.turnOffLocalCamera).toHaveBeenCalled();
+      expect(webRTCAdaptorConstructor.closeStream).toHaveBeenCalled();
     });
   });
 
   it('should clear participants and intervals when isPlayOnly changes', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
+
       const { rerender } = render(
           <ThemeProvider theme={theme(ThemeList.Green)}>
               <AntMedia isTest={true} isPlayOnly={false}>
-                  <MockChild/>
+                  <TestMockChild/>
               </AntMedia>
           </ThemeProvider>
       );
@@ -3553,26 +4027,31 @@ describe('AntMedia Component', () => {
 
       // Set some initial participants
       await act(async () => {
-          currentConference.setVideoTrackAssignments(['track1', 'track2']);
-          currentConference.setAllParticipants({ participant1: {}, participant2: {} });
+        testConference.setVideoTrackAssignments(['track1', 'track2']);
+        testConference.setAllParticipants({ participant1: {}, participant2: {} });
       });
       
       await act(async () => {
-        currentConference.setIsPlayOnly(true);
+        testConference.setIsPlayOnly(true);
       });
 
       // Verify participants are cleared
       await waitFor(() => {
-          expect(currentConference.videoTrackAssignments).toEqual([]);
-          expect(currentConference.allParticipants).toEqual({});
+          expect(testConference.videoTrackAssignments).toEqual([]);
+          expect(testConference.allParticipants).toEqual({});
       });
   });
 
   it('starts becoming publisher if in play only mode', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
+
     const {container} = render(
         <ThemeProvider theme={theme(ThemeList.Green)}>
           <AntMedia isTest={true}>
-            <MockChild/>
+            <TestMockChild/>
           </AntMedia>
         </ThemeProvider>);
 
@@ -3581,32 +4060,37 @@ describe('AntMedia Component', () => {
     });
 
     await act(async () => {
-      currentConference.setIsPlayOnly(true);
+      testConference.setIsPlayOnly(true);
     });
 
     await act(async () => {
-      currentConference.setIsPlayOnly = jest.fn();
-      currentConference.setInitialized = jest.fn();
-      currentConference.setWaitingOrMeetingRoom = jest.fn();
-      currentConference.joinRoom = jest.fn();
+      testConference.setIsPlayOnly = jest.fn();
+      testConference.setInitialized = jest.fn();
+      testConference.setWaitingOrMeetingRoom = jest.fn();
+      testConference.joinRoom = jest.fn();
     });
 
     await act(async () => {
-      currentConference.handleStartBecomePublisher();
+      testConference.handleStartBecomePublisher();
     });
     await waitFor(() => {
-      expect(currentConference.setIsPlayOnly).not.toHaveBeenCalledWith(false);
-      expect(currentConference.setInitialized).not.toHaveBeenCalledWith(false);
-      expect(currentConference.setWaitingOrMeetingRoom).not.toHaveBeenCalledWith("waiting");
-      expect(currentConference.joinRoom).not.toHaveBeenCalledWith(currentConference.roomName, currentConference.publishStreamId);
+      expect(testConference.setIsPlayOnly).not.toHaveBeenCalledWith(false);
+      expect(testConference.setInitialized).not.toHaveBeenCalledWith(false);
+      expect(testConference.setWaitingOrMeetingRoom).not.toHaveBeenCalledWith("waiting");
+      expect(testConference.joinRoom).not.toHaveBeenCalledWith(testConference.roomName, testConference.publishStreamId);
     });
   });
 
   it('rejects become speaker request', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
+
     const {container} = render(
         <ThemeProvider theme={theme(ThemeList.Green)}>
           <AntMedia isTest={true}>
-            <MockChild/>
+            <TestMockChild/>
           </AntMedia>
         </ThemeProvider>);
 
@@ -3614,19 +4098,24 @@ describe('AntMedia Component', () => {
       expect(webRTCAdaptorConstructor).not.toBe(undefined);
     });
 
-    currentConference.handleSendNotificationEvent = jest.fn();
+    testConference.handleSendNotificationEvent = jest.fn();
     const streamId = 'testStreamId';
-    currentConference.rejectBecomeSpeakerRequest(streamId);
-    expect(currentConference.handleSendNotificationEvent).not.toHaveBeenCalledWith("REJECT_BECOME_PUBLISHER", currentConference.roomName, {
+    testConference.rejectBecomeSpeakerRequest(streamId);
+    expect(testConference.handleSendNotificationEvent).not.toHaveBeenCalledWith("REJECT_BECOME_PUBLISHER", testConference.roomName, {
       senderStreamId: streamId
     });
   });
 
   it('handles REQUEST_BECOME_PUBLISHER event when role is Host', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
+
     const { container } = render(
         <ThemeProvider theme={theme(ThemeList.Green)}>
           <AntMedia isTest={true}>
-            <MockChild/>
+            <TestMockChild/>
           </AntMedia>
         </ThemeProvider>
     );
@@ -3636,7 +4125,7 @@ describe('AntMedia Component', () => {
     });
 
     await act(() => {
-      currentConference.setPublishStreamId('testStreamId');
+      testConference.setPublishStreamId('testStreamId');
     });
 
     const notificationEvent = {
@@ -3650,19 +4139,24 @@ describe('AntMedia Component', () => {
     };
 
     await act(async () => {
-      currentConference.handleNotificationEvent(obj);
+      testConference.handleNotificationEvent(obj);
     });
 
     await waitFor(() => {
-      expect(currentConference.requestSpeakerList).not.toContain('testStreamId');
+      expect(testConference.requestSpeakerList).not.toContain('testStreamId');
     });
   });
 
   it('does not handle REQUEST_BECOME_PUBLISHER event if request already received', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
+
     const { container } = render(
         <ThemeProvider theme={theme(ThemeList.Green)}>
           <AntMedia isTest={true}>
-            <MockChild/>
+            <TestMockChild/>
           </AntMedia>
         </ThemeProvider>
     );
@@ -3672,19 +4166,19 @@ describe('AntMedia Component', () => {
     });
 
     await act(() => {
-      currentConference.requestSpeakerList = ['testStreamIdListener'];
+      testConference.requestSpeakerList = ['testStreamIdListener'];
     });
 
     await act(() => {
-      currentConference.setRequestSpeakerList(['testStreamIdListener']);
+      testConference.setRequestSpeakerList(['testStreamIdListener']);
     });
 
     await act(() => {
-      currentConference.setPublishStreamId('testStreamIdHost');
+      testConference.setPublishStreamId('testStreamIdHost');
     });
 
     await act(() => {
-      currentConference.setRole(WebinarRoles.Host);
+      testConference.setRole(WebinarRoles.Host);
     });
 
     const notificationEvent = {
@@ -3700,7 +4194,7 @@ describe('AntMedia Component', () => {
     const consoleSpy = jest.spyOn(console, 'log').mockImplementation();
 
     await act(async () => {
-      currentConference.handleNotificationEvent(obj);
+      testConference.handleNotificationEvent(obj);
     });
 
     expect(consoleSpy).toHaveBeenCalledWith("Request is already received from ", 'testStreamIdListener');
@@ -3708,10 +4202,15 @@ describe('AntMedia Component', () => {
   });
 
   it('handles MAKE_LISTENER_AGAIN event when role is TempListener', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
+
     const { container } = render(
         <ThemeProvider theme={theme(ThemeList.Green)}>
           <AntMedia isTest={true}>
-            <MockChild/>
+            <TestMockChild/>
           </AntMedia>
         </ThemeProvider>
     );
@@ -3721,7 +4220,7 @@ describe('AntMedia Component', () => {
     });
 
     await act(() => {
-      currentConference.setRole(WebinarRoles.TempListener);
+      testConference.setRole(WebinarRoles.TempListener);
     });
 
     const notificationEvent = {
@@ -3735,19 +4234,24 @@ describe('AntMedia Component', () => {
     };
 
     await act(async () => {
-      currentConference.handleNotificationEvent(obj);
+      testConference.handleNotificationEvent(obj);
     });
 
     await waitFor(() => {
-      expect(currentConference.isPlayOnly).toBe(true);
+      expect(testConference.isPlayOnly).toBe(true);
     });
   });
 
   it('handles APPROVE_BECOME_PUBLISHER event when role is Listener', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
+
     const { container } = render(
         <ThemeProvider theme={theme(ThemeList.Green)}>
           <AntMedia isTest={true}>
-            <MockChild/>
+            <TestMockChild/>
           </AntMedia>
         </ThemeProvider>
     );
@@ -3757,11 +4261,11 @@ describe('AntMedia Component', () => {
     });
 
     await act(() => {
-      currentConference.setRole(WebinarRoles.Listener);
+      testConference.setRole(WebinarRoles.Listener);
     });
 
     await act(() => {
-      currentConference.setPublishStreamId('testStreamId');
+      testConference.setPublishStreamId('testStreamId');
     });
 
     const notificationEvent = {
@@ -3775,19 +4279,24 @@ describe('AntMedia Component', () => {
     };
 
     await act(async () => {
-      currentConference.handleNotificationEvent(obj);
+      testConference.handleNotificationEvent(obj);
     });
 
     await waitFor(() => {
-      expect(currentConference.isPlayOnly).toBe(false);
+      expect(testConference.isPlayOnly).toBe(false);
     });
   });
 
   it('handles REJECT_BECOME_PUBLISHER event when role is Listener', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
+
     const { container } = render(
         <ThemeProvider theme={theme(ThemeList.Green)}>
           <AntMedia isTest={true}>
-            <MockChild/>
+            <TestMockChild/>
           </AntMedia>
         </ThemeProvider>
     );
@@ -3797,11 +4306,11 @@ describe('AntMedia Component', () => {
     });
 
     await act(() => {
-      currentConference.setRole(WebinarRoles.Listener);
+      testConference.setRole(WebinarRoles.Listener);
     });
 
     await act(() => {
-      currentConference.setPublishStreamId('testStreamId');
+      testConference.setPublishStreamId('testStreamId');
     });
 
     const notificationEvent = {
@@ -3815,25 +4324,30 @@ describe('AntMedia Component', () => {
     };
 
     await act(async () => {
-      currentConference.showInfoSnackbarWithLatency = jest.fn();
+      testConference.showInfoSnackbarWithLatency = jest.fn();
     });
 
     await act(async () => {
-      currentConference.handleNotificationEvent(obj);
+      testConference.handleNotificationEvent(obj);
     });
 
     await waitFor(() => {
-      expect(currentConference.role).toBe(WebinarRoles.Listener);
+      expect(testConference.role).toBe(WebinarRoles.Listener);
     });
   });
 
 
   it('test play only participant join room', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
+
     const consoleSpy = jest.spyOn(console, 'log').mockImplementation();
 
     const { container } = render(
         <AntMedia isTest={true}>
-          <MockChild/>
+          <TestMockChild/>
         </AntMedia>);
 
     await waitFor(() => {
@@ -3841,7 +4355,7 @@ describe('AntMedia Component', () => {
     });
 
     await act(async () => {
-      currentConference.setIsPlayOnly(true);
+      testConference.setIsPlayOnly(true);
     });
 
     await act(async () => {
@@ -3849,16 +4363,21 @@ describe('AntMedia Component', () => {
     });
 
     await waitFor(() => {
-      currentConference.joinRoom("room", "publishStreamId");
+      testConference.joinRoom("room", "publishStreamId");
     });
 
     consoleSpy.mockRestore();
   });
 
   it('test not updating devices unless initialized ', async () => {
+    let testConference;
+    const TestMockChild = createMockChild(conf => {
+      testConference = conf;
+    });
+
     const { container } = render(
         <AntMedia isTest={true}>
-          <MockChild/>
+          <TestMockChild/>
         </AntMedia>);
 
     await waitFor(() => {
@@ -3875,11 +4394,11 @@ describe('AntMedia Component', () => {
     const updateMetaData = jest.spyOn(webRTCAdaptorConstructor, 'updateStreamMetaData').mockImplementation();
 
     await act(async () => {
-      currentConference.setInitialized(false);
+      testConference.setInitialized(false);
     });
 
     await act(async () => {
-      currentConference.setDevices(mockDevices);
+      testConference.setDevices(mockDevices);
     });
 
     jest.useFakeTimers();
@@ -3891,6 +4410,4 @@ describe('AntMedia Component', () => {
 
     consoleSpy.mockRestore();
   });
-});
-
-
+});
\ No newline at end of file

From 90d0371d19f6ec36c470494e38c6bc72a10db3bd Mon Sep 17 00:00:00 2001
From: golgetahir <tahir.golge@gmail.com>
Date: Tue, 4 Mar 2025 13:53:30 +0300
Subject: [PATCH 08/11] Update variable names

---
 react/src/__tests__/pages/AntMedia.test.js | 1072 ++++++++++----------
 1 file changed, 533 insertions(+), 539 deletions(-)

diff --git a/react/src/__tests__/pages/AntMedia.test.js b/react/src/__tests__/pages/AntMedia.test.js
index 616d733a..d557e526 100644
--- a/react/src/__tests__/pages/AntMedia.test.js
+++ b/react/src/__tests__/pages/AntMedia.test.js
@@ -179,8 +179,6 @@ const mediaDevicesMock = {
 const enqueueSnackbar = jest.fn();
 
 describe('AntMedia Component', () => {
-  // Local variables for this describe block
-  let currentConference;
 
   beforeEach(() => {
     console.log("---------------------------");
@@ -194,9 +192,6 @@ describe('AntMedia Component', () => {
     createdAdaptors.publishSpeedTest = [];
     createdAdaptors.publishSpeedTestPlayOnly = [];
     createdAdaptors.playSpeedTest = [];
-    
-    // Reset local conference reference
-    currentConference = undefined;
 
     // Setup mock web socket
     websocketSendMessage = jest.fn();
@@ -224,7 +219,6 @@ describe('AntMedia Component', () => {
     webRTCAdaptorPublishSpeedTestPlayOnlyConstructor = undefined;
     webRTCAdaptorPublishSpeedTestConstructor = undefined;
     webRTCAdaptorPlaySpeedTestConstructor = undefined;
-    currentConference = undefined;
     console.log(`Finished test: ${expect.getState().currentTestName}`);
     console.log("---------------------------");
   });
@@ -240,9 +234,9 @@ describe('AntMedia Component', () => {
 
   it('share screen', async () => {
     // Create a local conference reference for this test
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     const { container } = render(
@@ -250,10 +244,10 @@ describe('AntMedia Component', () => {
           <TestMockChild/>
         </AntMedia>);
 
-    expect(testConference.isScreenShared).toBe(false);
+    expect(currentConference.isScreenShared).toBe(false);
 
     await act(async () => {
-      testConference.handleStartScreenShare();
+      currentConference.handleStartScreenShare();
     });
 
     await waitFor(() => {
@@ -265,15 +259,15 @@ describe('AntMedia Component', () => {
     });
 
     await waitFor(() => {
-      expect(testConference.isScreenShared).toBe(true);
+      expect(currentConference.isScreenShared).toBe(true);
     });
 
-    console.log(testConference);
+    console.log(currentConference);
 
-    expect(testConference.isScreenShared).toBe(true);
+    expect(currentConference.isScreenShared).toBe(true);
 
     await act(()=> {
-      testConference.handleStopScreenShare();
+      currentConference.handleStopScreenShare();
     });
 
     expect(webRTCAdaptorScreenConstructor.closeStream).toHaveBeenCalled();
@@ -283,9 +277,9 @@ describe('AntMedia Component', () => {
 
   it('share screen adaptor callbacks', async () => {
     // Create a local conference reference for this test
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     const consoleSpy = jest.spyOn(console, 'log').mockImplementation();
@@ -297,10 +291,10 @@ describe('AntMedia Component', () => {
     //console.log(container);
 
 
-    expect(testConference.isScreenShared).toBe(false);
+    expect(currentConference.isScreenShared).toBe(false);
 
     await act(async () => {
-      testConference.handleStartScreenShare();
+      currentConference.handleStartScreenShare();
     });
 
     await waitFor(() => {
@@ -383,9 +377,9 @@ describe('AntMedia Component', () => {
 
 
   it('handle sharing on', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     const { container } = render(
@@ -399,7 +393,7 @@ describe('AntMedia Component', () => {
 
     var testStreamId = "stream1";
 
-    testConference.videoTrackAssignments.push({streamId: testStreamId, videoLabel: "test1"});
+    currentConference.videoTrackAssignments.push({streamId: testStreamId, videoLabel: "test1"});
     var obj = {};
     var notificationEvent = {
       eventType: "SCREEN_SHARED_ON",
@@ -416,9 +410,9 @@ describe('AntMedia Component', () => {
   });
 
   it('publishTimeoutError error callback', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
     const { container } = render(
         <AntMedia isTest={true}>
@@ -436,20 +430,20 @@ describe('AntMedia Component', () => {
     });
 
     await act(async () => {
-      expect(testConference.leaveRoomWithError == "Firewall might be blocking your connection. Please report this.");
+      expect(currentConference.leaveRoomWithError == "Firewall might be blocking your connection. Please report this.");
     });
 
     await act(async () => {
-      expect(testConference.leftTheRoom == true);
+      expect(currentConference.leftTheRoom == true);
     });
 
     consoleSpy.mockRestore();
   });
 
   it('license_suspended_please_renew_license error callback', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     const { container } = render(
@@ -476,9 +470,9 @@ describe('AntMedia Component', () => {
   });
 
   it('notSetRemoteDescription error callback', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     const { container } = render(
@@ -505,9 +499,9 @@ describe('AntMedia Component', () => {
   });
 
   it('max video count setting', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     const { container } = render(
@@ -522,23 +516,23 @@ describe('AntMedia Component', () => {
     });
 
     await waitFor(() => {
-      testConference.joinRoom("room", "publishStreamId");
+      currentConference.joinRoom("room", "publishStreamId");
     });
 
     await act(async () => {
-      testConference.handleSetDesiredTileCount(5);
+      currentConference.handleSetDesiredTileCount(5);
     });
 
     await waitFor(() => {
-      expect(testConference.globals.desiredTileCount).toBe(5);
+      expect(currentConference.globals.desiredTileCount).toBe(5);
     });
 
     await act(async () => {
-      testConference.updateMaxVideoTrackCount(7);
+      currentConference.updateMaxVideoTrackCount(7);
     });
 
     await waitFor(() => {
-      expect(testConference.globals.maxVideoTrackCount).toBe(7);
+      expect(currentConference.globals.maxVideoTrackCount).toBe(7);
     });
 
     consoleSpy.mockRestore();
@@ -546,9 +540,9 @@ describe('AntMedia Component', () => {
   });
 
   it('start with camera and microphone', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
     mediaDevicesMock.enumerateDevices.mockResolvedValue([
       { deviceId: '1', kind: 'videoinput' },
@@ -560,15 +554,15 @@ describe('AntMedia Component', () => {
           <TestMockChild/>
         </AntMedia>);
 
-    expect(testConference.cameraButtonDisabled === false);
-    expect(testConference.microphoneButtonDisabled === false);
+    expect(currentConference.cameraButtonDisabled === false);
+    expect(currentConference.microphoneButtonDisabled === false);
 
   });
 
   it('start with one microphone and without any camera', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     mediaDevicesMock.enumerateDevices.mockResolvedValue([
@@ -580,15 +574,15 @@ describe('AntMedia Component', () => {
           <TestMockChild/>
         </AntMedia>);
 
-    expect(testConference.cameraButtonDisabled === true);
-    expect(testConference.microphoneButtonDisabled === false);
+    expect(currentConference.cameraButtonDisabled === true);
+    expect(currentConference.microphoneButtonDisabled === false);
 
   });
 
   it('start with one camera and without any microphone', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     mediaDevicesMock.enumerateDevices.mockResolvedValue([
@@ -600,15 +594,15 @@ describe('AntMedia Component', () => {
           <TestMockChild/>
         </AntMedia>);
 
-    expect(testConference.cameraButtonDisabled === false);
-    expect(testConference.microphoneButtonDisabled === true);
+    expect(currentConference.cameraButtonDisabled === false);
+    expect(currentConference.microphoneButtonDisabled === true);
 
   });
 
   it('start without camera nor microphone', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     mediaDevicesMock.enumerateDevices.mockResolvedValue([
@@ -619,15 +613,15 @@ describe('AntMedia Component', () => {
           <TestMockChild/>
         </AntMedia>);
 
-    expect(testConference.cameraButtonDisabled === true);
-    expect(testConference.microphoneButtonDisabled === true);
+    expect(currentConference.cameraButtonDisabled === true);
+    expect(currentConference.microphoneButtonDisabled === true);
 
   });
 
   it('should enable camera and microphone buttons if selected devices are available', async () => {
-    let testConference;   
+    let currentConference;   
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     const { container } = render(
@@ -642,18 +636,18 @@ describe('AntMedia Component', () => {
 
     // Execute the function
     await act(async () => {
-      testConference.checkAndUpdateVideoAudioSources();
+      currentConference.checkAndUpdateVideoAudioSources();
     });
 
     // Expectations
-    expect(testConference.cameraButtonDisabled === false);
-    expect(testConference.microphoneButtonDisabled === false);
+    expect(currentConference.cameraButtonDisabled === false);
+    expect(currentConference.microphoneButtonDisabled === false);
   });
 
   it('should disable microphone button if no microphone is available', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     const { container } = render(
@@ -671,13 +665,13 @@ describe('AntMedia Component', () => {
       {videoDeviceId: '2'},
     ]);
 
-    testConference.devices = [];
+    currentConference.devices = [];
 
     const consoleSpy = jest.spyOn(console, 'info').mockImplementation();
 
     // Execute the function
     await act(async () => {
-      testConference.checkAndUpdateVideoAudioSources();
+      currentConference.checkAndUpdateVideoAudioSources();
     });
 
     // Expectations
@@ -686,9 +680,9 @@ describe('AntMedia Component', () => {
   });
 
   it('should disable microphone button if no microphone is available', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     const { container } = render(
@@ -707,13 +701,13 @@ describe('AntMedia Component', () => {
       {audioDeviceId: '2'},
     ]);
 
-    testConference.devices = [];
+    currentConference.devices = [];
 
     const consoleSpy = jest.spyOn(console, 'info').mockImplementation();
 
     // Execute the function
     await act(async () => {
-      testConference.checkAndUpdateVideoAudioSources();
+      currentConference.checkAndUpdateVideoAudioSources();
     });
 
     // Expectations
@@ -722,9 +716,9 @@ describe('AntMedia Component', () => {
   });
 
   it('should switching the first available camera due to selected camera is not available', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     mediaDevicesMock.enumerateDevices.mockResolvedValue([
@@ -747,20 +741,20 @@ describe('AntMedia Component', () => {
     });
 
     await act(async () => {
-      testConference.setSelectedCamera("camera1");
+      currentConference.setSelectedCamera("camera1");
     });
 
     await waitFor(() => {
-      expect(testConference.selectedCamera).toBe("camera1");
+      expect(currentConference.selectedCamera).toBe("camera1");
     });
 
     const consoleSpy = jest.spyOn(console, 'info').mockImplementation();
 
-    console.log(testConference.getSelectedDevices());
+    console.log(currentConference.getSelectedDevices());
 
     // Execute the function
     await act(async () => {
-      testConference.checkAndUpdateVideoAudioSources();
+      currentConference.checkAndUpdateVideoAudioSources();
     });
 
     // Expectations
@@ -770,9 +764,9 @@ describe('AntMedia Component', () => {
 
 
   it('should switching the first available microphone due to selected microphone is not available', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     mediaDevicesMock.enumerateDevices.mockResolvedValue([
@@ -795,20 +789,20 @@ describe('AntMedia Component', () => {
     });
 
     await act(async () => {
-      testConference.setSelectedMicrophone("mic1");
+      currentConference.setSelectedMicrophone("mic1");
     });
 
     await waitFor(() => {
-      expect(testConference.selectedMicrophone).toBe("mic1");
+      expect(currentConference.selectedMicrophone).toBe("mic1");
     });
 
     const consoleSpy = jest.spyOn(console, 'info').mockImplementation();
 
-    console.log(testConference.getSelectedDevices());
+    console.log(currentConference.getSelectedDevices());
 
     // Execute the function
     await act(async () => {
-      testConference.checkAndUpdateVideoAudioSources();
+      currentConference.checkAndUpdateVideoAudioSources();
     });
 
     // Expectations
@@ -817,9 +811,9 @@ describe('AntMedia Component', () => {
   });
 
   it('is joining state test', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     const { container } = render(
@@ -834,15 +828,15 @@ describe('AntMedia Component', () => {
       expect(webRTCAdaptorConstructor).not.toBe(undefined);
     });
 
-    expect(testConference.isJoining).toBe(false);
+    expect(currentConference.isJoining).toBe(false);
 
     const consoleSpy = jest.spyOn(console, 'error').mockImplementation();
 
     await act(async () => {
-      testConference.setIsJoining(true);
+      currentConference.setIsJoining(true);
     });
 
-    expect(testConference.isJoining).toBe(true);
+    expect(currentConference.isJoining).toBe(true);
 
     await act(async () => {
       webRTCAdaptorConstructor.callback("publish_started");
@@ -853,16 +847,16 @@ describe('AntMedia Component', () => {
     });
 
 
-    expect(testConference.isJoining).toBe(false);
+    expect(currentConference.isJoining).toBe(false);
 
     consoleSpy.mockRestore();
 
   });
 
   it('is joining state for playonly', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     const { container } = render(
@@ -877,32 +871,32 @@ describe('AntMedia Component', () => {
       expect(webRTCAdaptorConstructor).not.toBe(undefined);
     });
 
-    expect(testConference.isJoining).toBe(false);
+    expect(currentConference.isJoining).toBe(false);
 
     const consoleSpy = jest.spyOn(console, 'error').mockImplementation();
 
     await act(async () => {
-      testConference.setIsJoining(true);
-      testConference.setIsPlayOnly(true);
+      currentConference.setIsJoining(true);
+      currentConference.setIsPlayOnly(true);
     });
 
-    expect(testConference.isJoining).toBe(true);
+    expect(currentConference.isJoining).toBe(true);
 
     await act(async () => {
       webRTCAdaptorConstructor.callback("play_started");
     });
 
 
-    expect(testConference.isJoining).toBe(false);
+    expect(currentConference.isJoining).toBe(false);
 
     consoleSpy.mockRestore();
 
   });
 
   it('playonly join when noone in the room', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     const { container } = render(
@@ -917,17 +911,17 @@ describe('AntMedia Component', () => {
       expect(webRTCAdaptorConstructor).not.toBe(undefined);
     });
 
-    expect(testConference.isJoining).toBe(false);
+    expect(currentConference.isJoining).toBe(false);
 
     const consoleSpy = jest.spyOn(console, 'error').mockImplementation();
 
     await act(async () => {
-      testConference.setIsJoining(true);
-      testConference.setIsPlayOnly(true);
+      currentConference.setIsJoining(true);
+      currentConference.setIsPlayOnly(true);
       webRTCAdaptorConstructor.callbackError("no_stream_exist");
     });
 
-    expect(testConference.isJoining).toBe(true);
+    expect(currentConference.isJoining).toBe(true);
 
     await waitFor(() => {
       expect(container.outerHTML).toContain("The room is currently empty");
@@ -938,16 +932,16 @@ describe('AntMedia Component', () => {
     });
 
 
-    expect(testConference.isJoining).toBe(false);
+    expect(currentConference.isJoining).toBe(false);
 
     consoleSpy.mockRestore();
 
   });
 
   it('is reconnection in progress state test', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     const { container } = render(
@@ -993,9 +987,9 @@ describe('AntMedia Component', () => {
   });
 
   it('is reconnection in progress state test because of publisher', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     const { container } = render(
@@ -1048,9 +1042,9 @@ describe('AntMedia Component', () => {
   */
 
   it('check publisher stucks on reconnection issue', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     const { container } = render(
@@ -1120,9 +1114,9 @@ describe('AntMedia Component', () => {
 
 
   it('is reconnection in progress state for playonly', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     const { container } = render(
@@ -1139,7 +1133,7 @@ describe('AntMedia Component', () => {
     expect(container.outerHTML).not.toContain("Reconnecting...");
 
     await act(async () => {
-      testConference.setIsPlayOnly(true);
+      currentConference.setIsPlayOnly(true);
     });
 
     await act(async () => {
@@ -1163,9 +1157,9 @@ describe('AntMedia Component', () => {
 
 
   it('test fix for duplicated tile after reconnection', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     const { container } = render(
@@ -1194,18 +1188,18 @@ describe('AntMedia Component', () => {
       expect(container.outerHTML).toContain("Reconnecting...");
     });
 
-    expect(testConference.videoTrackAssignments).toHaveLength(1);
+    expect(currentConference.videoTrackAssignments).toHaveLength(1);
 
-    expect(testConference.videoTrackAssignments[0].isMine).toBe(true);
+    expect(currentConference.videoTrackAssignments[0].isMine).toBe(true);
 
     await act(async () => {
       webRTCAdaptorConstructor.callback("newTrackAvailable", {"trackId" : "ARDAMSvvideoTrack0", "streamId":"room1", "track": {id: "someId", kind: "video"}});
     });
 
-    expect(testConference.videoTrackAssignments).toHaveLength(2);
+    expect(currentConference.videoTrackAssignments).toHaveLength(2);
 
-    expect(testConference.videoTrackAssignments[1].videoLabel).toBe("videoTrack0");
-    expect(testConference.videoTrackAssignments[1].streamId).toBe("room1");
+    expect(currentConference.videoTrackAssignments[1].videoLabel).toBe("videoTrack0");
+    expect(currentConference.videoTrackAssignments[1].streamId).toBe("room1");
 
 
     var notificationEvent = {
@@ -1223,17 +1217,17 @@ describe('AntMedia Component', () => {
       webRTCAdaptorConstructor.callback("data_received", obj);
     });
 
-    expect(testConference.videoTrackAssignments).toHaveLength(2);
+    expect(currentConference.videoTrackAssignments).toHaveLength(2);
 
-    expect(testConference.videoTrackAssignments[1].videoLabel).toBe("videoTrack0");
-    expect(testConference.videoTrackAssignments[1].streamId).toBe("participant1");
+    expect(currentConference.videoTrackAssignments[1].videoLabel).toBe("videoTrack0");
+    expect(currentConference.videoTrackAssignments[1].streamId).toBe("participant1");
 
   });
 
   it('calls removeAllRemoteParticipants without crashing', () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     let contextValue = {
@@ -1257,9 +1251,9 @@ describe('AntMedia Component', () => {
 
   it('handleLeaveFromRoom#closeStream', async () => {
     // Create a local reference for this test
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     const { container } = render(
@@ -1275,15 +1269,15 @@ describe('AntMedia Component', () => {
     let publishStreamId = "publishStreamId";
 
     await act(async () => {
-      testConference.setRoomName(roomName);
+      currentConference.setRoomName(roomName);
     });
 
     await act(async () => {
-      testConference.setPublishStreamId(publishStreamId);
+      currentConference.setPublishStreamId(publishStreamId);
     });
 
     await act(async () => {
-      testConference.handleLeaveFromRoom();
+      currentConference.handleLeaveFromRoom();
     });
 
     expect(webRTCAdaptorConstructor.closeStream).toHaveBeenCalled();
@@ -1293,9 +1287,9 @@ describe('AntMedia Component', () => {
 
   it('screen sharing state test', async () => {
     // Create a local reference for this test
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     const { container } = render(
@@ -1305,10 +1299,10 @@ describe('AntMedia Component', () => {
           </AntMedia>
         </ThemeProvider>);
 
-    expect(testConference.isScreenShared).toBe(false);
+    expect(currentConference.isScreenShared).toBe(false);
 
     await act(async () => {
-      testConference.handleStartScreenShare();
+      currentConference.handleStartScreenShare();
     });
 
     await waitFor(() => {
@@ -1329,9 +1323,9 @@ describe('AntMedia Component', () => {
 
   it('screen sharing test', async () => {
 
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
     const {container} = render(
         <ThemeProvider theme={theme(ThemeList.Green)}>
@@ -1345,15 +1339,15 @@ describe('AntMedia Component', () => {
     });
 
     const consoleSpy = jest.spyOn(console, 'error').mockImplementation();
-    testConference.setParticipantUpdated = jest.fn();
+    currentConference.setParticipantUpdated = jest.fn();
 
-    testConference.allParticipants["participant0"] = {videoTrackId: "participant0", isPinned: false};
-    testConference.allParticipants["participant1"] = {videoTrackId: "participant1", isPinned: false};
-    testConference.allParticipants["participant2"] = {videoTrackId: "participant2", isPinned: false};
-    testConference.allParticipants["participant3"] = {videoTrackId: "participant3", isPinned: false};
+    currentConference.allParticipants["participant0"] = {videoTrackId: "participant0", isPinned: false};
+    currentConference.allParticipants["participant1"] = {videoTrackId: "participant1", isPinned: false};
+    currentConference.allParticipants["participant2"] = {videoTrackId: "participant2", isPinned: false};
+    currentConference.allParticipants["participant3"] = {videoTrackId: "participant3", isPinned: false};
 
     await act(async () => {
-      testConference.setVideoTrackAssignments([
+      currentConference.setVideoTrackAssignments([
         {videoLabel: "participant0", streamId: "participant0", videoTrackId: "participant0", audioTrackId: "participant0", isReserved: false},
         {videoLabel: "participant1", streamId: "participant1", videoTrackId: "participant1", audioTrackId: "participant1", isReserved: false},
         {videoLabel: "participant2", streamId: "participant2", videoTrackId: "participant2", audioTrackId: "participant2", isReserved: false},
@@ -1363,31 +1357,31 @@ describe('AntMedia Component', () => {
 
     // testing pinning
     await act(async () => {
-      testConference.pinVideo("participant3");
+      currentConference.pinVideo("participant3");
     });
 
     await waitFor(() => {
-      expect(testConference.currentPinInfo.streamId).toBe('participant3');
+      expect(currentConference.currentPinInfo.streamId).toBe('participant3');
     });
 
     // testing pinning while another participant is pinned
     await act(async () => {
-      testConference.pinVideo("participant2");
+      currentConference.pinVideo("participant2");
     });
 
-    expect(testConference.currentPinInfo.streamId).toBe('participant2');
+    expect(currentConference.currentPinInfo.streamId).toBe('participant2');
 
 
     // testing unpinning
     await act(async () => {
-      testConference.unpinVideo();
+      currentConference.unpinVideo();
     });
 
-    expect(testConference.currentPinInfo).toBe(null);
+    expect(currentConference.currentPinInfo).toBe(null);
 
     // testing pinning a non-existing participant
     await act(async () => {
-      testConference.pinVideo("non-exist-participant");
+      currentConference.pinVideo("non-exist-participant");
     });
 
     expect(consoleSpy).toHaveBeenCalledWith("Cannot find broadcast object for streamId: non-exist-participant");
@@ -1395,9 +1389,9 @@ describe('AntMedia Component', () => {
   });
 
   it('high resource usage', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     const { container } = render(
@@ -1414,10 +1408,10 @@ describe('AntMedia Component', () => {
 
     webRTCAdaptorConstructor.closeWebSocket = jest.fn();
 
-    expect(testConference.isJoining).toBe(false);
+    expect(currentConference.isJoining).toBe(false);
 
     await act(async () => {
-      testConference.joinRoom("room", "publishStreamId");
+      currentConference.joinRoom("room", "publishStreamId");
     });
 
     await act(async () => {
@@ -1434,9 +1428,9 @@ describe('AntMedia Component', () => {
   });
 
   it('audio level setting test', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     }); 
 
     const { container } = render(
@@ -1454,7 +1448,7 @@ describe('AntMedia Component', () => {
     const consoleSpy = jest.spyOn(console, 'error').mockImplementation();
 
     await act(async () => {
-      testConference.setMicAudioLevel(10);
+      currentConference.setMicAudioLevel(10);
     });
     expect(webRTCAdaptorConstructor.setVolumeLevel).toHaveBeenCalledWith(10);
 
@@ -1463,9 +1457,9 @@ describe('AntMedia Component', () => {
   });
 
   it('checks connection quality and displays warning for poor network connection for publish', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     const { container } = render(
@@ -1572,9 +1566,9 @@ describe('AntMedia Component', () => {
   });
 
   it('checks connection quality and displays warning for poor network connection for playback', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     const { container } = render(
@@ -1696,11 +1690,11 @@ describe('AntMedia Component', () => {
   });
 
   describe('Screen render test', () => {
-    let testConference;
+    let currentConference;
 
     // Use the createMockChild function defined earlier to avoid the linter error
     const TestMockChild = createMockChild(conference => {
-      testConference = conference;
+      currentConference = conference;
     });
 
     it('should update participantUpdated state every 5 seconds', async () => {
@@ -1720,13 +1714,13 @@ describe('AntMedia Component', () => {
         jest.advanceTimersByTime(8000);
       });
 
-      expect(testConference.participantUpdated).toBe(true);
+      expect(currentConference.participantUpdated).toBe(true);
 
       act(() => {
         jest.advanceTimersByTime(8000);
       });
 
-      expect(testConference.participantUpdated).toBe(true);
+      expect(currentConference.participantUpdated).toBe(true);
 
       jest.useRealTimers();
     });
@@ -1748,13 +1742,13 @@ describe('AntMedia Component', () => {
         jest.advanceTimersByTime(8000);
       });
 
-      expect(testConference.participantUpdated).toBe(true);
+      expect(currentConference.participantUpdated).toBe(true);
 
       act(() => {
         jest.advanceTimersByTime(8000);
       });
 
-      expect(testConference.participantUpdated).toBe(true);
+      expect(currentConference.participantUpdated).toBe(true);
 
       jest.useRealTimers();
     });
@@ -1762,9 +1756,9 @@ describe('AntMedia Component', () => {
 
   // Why there are 2 tests with the same name?
   it('fake reconnection', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     const { container } = render(
@@ -1869,9 +1863,9 @@ describe('AntMedia Component', () => {
   });
 
   it('fake reconnection', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     const { container } = render(
@@ -1884,10 +1878,10 @@ describe('AntMedia Component', () => {
       expect(webRTCAdaptorConstructor).not.toBe(undefined);
     });
 
-    expect(testConference.isScreenShared).toBe(false);
+    expect(currentConference.isScreenShared).toBe(false);
 
     await act(async () => {
-      testConference.handleStartScreenShare();
+      currentConference.handleStartScreenShare();
     });
 
     await waitFor(() => {
@@ -1900,12 +1894,12 @@ describe('AntMedia Component', () => {
 
 
     await waitFor(() => {
-      expect(testConference.isScreenShared).toBe(true);
+      expect(currentConference.isScreenShared).toBe(true);
     });
 
-    console.log(testConference);
+    console.log(currentConference);
 
-    expect(testConference.isScreenShared).toBe(true);
+    expect(currentConference.isScreenShared).toBe(true);
 
     webRTCAdaptorConstructor.reconnectIfRequired = jest.fn();
     webRTCAdaptorConstructor.requestVideoTrackAssignments = jest.fn();
@@ -1922,7 +1916,7 @@ describe('AntMedia Component', () => {
 
     await act(async () => {
       jest.useFakeTimers();
-      testConference.fakeReconnect();
+      currentConference.fakeReconnect();
       expect(webRTCAdaptorConstructor.iceConnectionState()).toBe("disconnected");
       jest.runAllTimers();
     });
@@ -1938,9 +1932,9 @@ describe('AntMedia Component', () => {
 
 
   it('checks connection quality and displays warning for poor network connection', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     let stopSpeedTest = jest.fn();
@@ -2065,9 +2059,9 @@ describe('AntMedia Component', () => {
 
 
   it('should stop and nullify speedTestForPublishWebRtcAdaptor when it is defined', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     const { container } = render(
@@ -2082,7 +2076,7 @@ describe('AntMedia Component', () => {
     });
 
     await act(async () => {
-      testConference.startSpeedTest();
+      currentConference.startSpeedTest();
     });
 
     await waitFor(() => {
@@ -2096,7 +2090,7 @@ describe('AntMedia Component', () => {
 
     // Act
     await act(async () => {
-      testConference.stopSpeedTest();
+      currentConference.stopSpeedTest();
     });
 
     jest.useFakeTimers();
@@ -2106,7 +2100,7 @@ describe('AntMedia Component', () => {
 
     // Assert
     await waitFor(() => {
-      expect(mockStop).toHaveBeenCalledWith(`speedTestStream${testConference.speedTestStreamId.current}`);
+      expect(mockStop).toHaveBeenCalledWith(`speedTestStream${currentConference.speedTestStreamId.current}`);
     });
 
     /*
@@ -2119,9 +2113,9 @@ describe('AntMedia Component', () => {
 
 
   it('should not throw error when speedTestForPublishWebRtcAdaptor is not defined', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     let stopSpeedTest = jest.fn();
@@ -2141,7 +2135,7 @@ describe('AntMedia Component', () => {
     // Act and Assert
     await expect(async () => {
       await act(async () => {
-        testConference?.stopSpeedTest();
+        currentConference?.stopSpeedTest();
       });
     }).not.toThrow();
   });
@@ -2149,9 +2143,9 @@ describe('AntMedia Component', () => {
 
 
   it('should stop and nullify speedTestForPlayWebRtcAdaptor when it is defined', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     const { container } = render(
@@ -2165,14 +2159,14 @@ describe('AntMedia Component', () => {
       expect(webRTCAdaptorConstructor).not.toBe(undefined);
     });
 
-    testConference.setIsPlayOnly(true);
+    currentConference.setIsPlayOnly(true);
 
     await waitFor(() => {
-      expect(testConference.isPlayOnly).toBe(true);
+      expect(currentConference.isPlayOnly).toBe(true);
     });
 
     await act(async () => {
-      testConference.startSpeedTest();
+      currentConference.startSpeedTest();
     });
 
     await waitFor(() => {
@@ -2189,7 +2183,7 @@ describe('AntMedia Component', () => {
 
     // Act
     await act(async () => {
-      testConference.stopSpeedTest();
+      currentConference.stopSpeedTest();
     });
 
     // Assert
@@ -2203,9 +2197,9 @@ describe('AntMedia Component', () => {
 
 
   it('should not throw error when speedTestForPlayWebRtcAdaptor is not defined', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     let stopSpeedTest = jest.fn();
@@ -2222,15 +2216,15 @@ describe('AntMedia Component', () => {
     // Act and Assert
     await expect(async () => {
       await act(async () => {
-        testConference?.stopSpeedTest();
+        currentConference?.stopSpeedTest();
       });
     }).not.toThrow();
   });
 
   it('notSetRemoteDescription error callback in reconnection', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     const { container } = render(
@@ -2273,9 +2267,9 @@ describe('AntMedia Component', () => {
   });
 
   it('license_suspended_please_renew_license error callback in reconnection', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     const { container } = render(
@@ -2316,9 +2310,9 @@ describe('AntMedia Component', () => {
 
 
   it('increments streamIdInUseCounter and does not leave room when counter is less than or equal to 3', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     const consoleSpy = jest.spyOn(console, 'log').mockImplementation();
@@ -2346,9 +2340,9 @@ describe('AntMedia Component', () => {
   });
 
   it('increments streamIdInUseCounter and leaves room with error when counter exceeds 3', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     const consoleSpy = jest.spyOn(console, 'log').mockImplementation();
@@ -2378,9 +2372,9 @@ describe('AntMedia Component', () => {
   });
 
   it('streamIdInUseCounter is not incremented due to reconnection is true', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     const consoleSpy = jest.spyOn(console, 'log').mockImplementation();
@@ -2414,9 +2408,9 @@ describe('AntMedia Component', () => {
   });
 
   it('updates allParticipants and participantUpdated when subtrackList is provided', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     const { container } = render(
@@ -2442,14 +2436,14 @@ describe('AntMedia Component', () => {
     });
 
     await waitFor(() => {
-      expect(testConference.participantUpdated).toBe(false);
+      expect(currentConference.participantUpdated).toBe(false);
     });
   });
 
   it('adds fake participants to allParticipants', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     const { container } = render(
@@ -2464,11 +2458,11 @@ describe('AntMedia Component', () => {
       expect(webRTCAdaptorConstructor).not.toBe(undefined);
     });
 
-    testConference.allParticipants["fakeStream1"] = {streamId: 'fakeStream1', isFake: true, videoTrackId: "participant0", parsedMetaData : {isScreenShared:false}};
+    currentConference.allParticipants["fakeStream1"] = {streamId: 'fakeStream1', isFake: true, videoTrackId: "participant0", parsedMetaData : {isScreenShared:false}};
 
     await waitFor(() => {
-      expect(testConference.allParticipants["fakeStream1"]).toBeDefined();
-      expect(testConference.allParticipants["fakeStream1"].isFake).toBe(true);
+      expect(currentConference.allParticipants["fakeStream1"]).toBeDefined();
+      expect(currentConference.allParticipants["fakeStream1"].isFake).toBe(true);
     });
 
     const subtrackList = [
@@ -2481,15 +2475,15 @@ describe('AntMedia Component', () => {
     });
 
     await waitFor(() => {
-      expect(testConference.allParticipants["fakeStream1"]).toBeDefined();
-      expect(testConference.participantUpdated).toBe(false);
+      expect(currentConference.allParticipants["fakeStream1"]).toBeDefined();
+      expect(currentConference.participantUpdated).toBe(false);
     });
   });
 
   it('handle the case if the metadata is empty', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     const { container } = render(
@@ -2515,14 +2509,14 @@ describe('AntMedia Component', () => {
     });
 
     await waitFor(() => {
-      expect(testConference.participantUpdated).toBe(false);
+      expect(currentConference.participantUpdated).toBe(false);
     });
   });
 
   it('does not update allParticipants if there are no changes', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     const { container } = render(
@@ -2537,7 +2531,7 @@ describe('AntMedia Component', () => {
       expect(webRTCAdaptorConstructor).not.toBe(undefined);
     });
 
-    testConference.allParticipants = {
+    currentConference.allParticipants = {
       'stream1': { streamId: 'stream1', isScreenShared: false }
     };
     const subtrackList = [
@@ -2550,14 +2544,14 @@ describe('AntMedia Component', () => {
     });
 
     await waitFor(() => {
-      expect(testConference.participantUpdated).toBe(false);
+      expect(currentConference.participantUpdated).toBe(false);
     });
   });
 
   it('sets allParticipants with "You" when not in play only mode', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     const { container } = render(
@@ -2572,11 +2566,11 @@ describe('AntMedia Component', () => {
       expect(webRTCAdaptorConstructor).not.toBe(undefined);
     });
 
-    testConference.allParticipants = {
+    currentConference.allParticipants = {
       'publishStreamId': { name: 'You' },
     };
 
-    testConference.isPlayOnly = false;
+    currentConference.isPlayOnly = false;
 
     const subtrackList = [
       JSON.stringify({ streamId: 'stream1', metaData: JSON.stringify({ isScreenShared: false }), receivedBytes: -1, duration: -1, bitrate: -1, updateTime: -1 })
@@ -2588,15 +2582,15 @@ describe('AntMedia Component', () => {
     });
 
     await waitFor(() => {
-      expect(testConference.participantUpdated).toBe(false);
+      expect(currentConference.participantUpdated).toBe(false);
     });
   });
 
   describe('fetchImageAsBlob', () => {
     it('returns a blob URL when the fetch is successful', async () => {
-      let testConference;
+      let currentConference;
       const TestMockChild = createMockChild(conf => {
-        testConference = conf;
+        currentConference = conf;
       });
 
       const { container } = render(
@@ -2618,7 +2612,7 @@ describe('AntMedia Component', () => {
       });
       global.URL.createObjectURL = jest.fn().mockReturnValue(mockUrl);
 
-      const result = await testConference.fetchImageAsBlob('http://example.com/image.png');
+      const result = await currentConference.fetchImageAsBlob('http://example.com/image.png');
 
       expect(result).toBe(mockUrl);
       expect(global.fetch).toHaveBeenCalledWith('http://example.com/image.png');
@@ -2626,9 +2620,9 @@ describe('AntMedia Component', () => {
     });
 
     it('throws an error when the fetch fails', async () => {
-      let testConference;
+      let currentConference;
       const TestMockChild = createMockChild(conf => {
-        testConference = conf;
+        currentConference = conf;
       });
 
       const { container } = render(
@@ -2645,13 +2639,13 @@ describe('AntMedia Component', () => {
 
       global.fetch = jest.fn().mockRejectedValue(new Error('Fetch failed'));
 
-      await expect(testConference.fetchImageAsBlob('http://example.com/image.png')).rejects.toThrow('Fetch failed');
+      await expect(currentConference.fetchImageAsBlob('http://example.com/image.png')).rejects.toThrow('Fetch failed');
     });
 
     it('throws an error when the blob conversion fails', async () => {
-      let testConference;
+      let currentConference;
       const TestMockChild = createMockChild(conf => {
-        testConference = conf;
+        currentConference = conf;
       });
 
       const { container } = render(
@@ -2670,15 +2664,15 @@ describe('AntMedia Component', () => {
         blob: jest.fn().mockRejectedValue(new Error('Blob conversion failed')),
       });
 
-      await expect(testConference.fetchImageAsBlob('http://example.com/image.png')).rejects.toThrow('Blob conversion failed');
+      await expect(currentConference.fetchImageAsBlob('http://example.com/image.png')).rejects.toThrow('Blob conversion failed');
     });
   });
 
   describe('setVirtualBackgroundImage', () => {
     it('returns immediately if the URL is undefined', async () => {
-      let testConference;
+      let currentConference;
       const TestMockChild = createMockChild(conf => {
-        testConference = conf;
+        currentConference = conf;
       });
 
       const {container} = render(
@@ -2693,14 +2687,14 @@ describe('AntMedia Component', () => {
         expect(webRTCAdaptorConstructor).not.toBe(undefined);
       });
 
-      const result = testConference.setVirtualBackgroundImage(undefined);
+      const result = currentConference.setVirtualBackgroundImage(undefined);
       expect(result).toBeUndefined();
     });
 
     it('returns immediately if the URL is null', async () => {
-      let testConference;
+      let currentConference;
       const TestMockChild = createMockChild(conf => {
-        testConference = conf;
+        currentConference = conf;
       });
 
       const { container } = render(
@@ -2715,14 +2709,14 @@ describe('AntMedia Component', () => {
         expect(webRTCAdaptorConstructor).not.toBe(undefined);
       });
 
-      const result = testConference.setVirtualBackgroundImage(null);
+      const result = currentConference.setVirtualBackgroundImage(null);
       expect(result).toBeUndefined();
     });
 
     it('returns immediately if the URL is an empty string', async () => {
-      let testConference;
+      let currentConference;
       const TestMockChild = createMockChild(conf => {
-        testConference = conf;
+        currentConference = conf;
       });
 
       const { container } = render(
@@ -2737,14 +2731,14 @@ describe('AntMedia Component', () => {
         expect(webRTCAdaptorConstructor).not.toBe(undefined);
       });
 
-      const result = testConference.setVirtualBackgroundImage('');
+      const result = currentConference.setVirtualBackgroundImage('');
       expect(result).toBeUndefined();
     });
 
     it('calls setAndEnableVirtualBackgroundImage if the URL starts with "data:image"', async () => {
-      let testConference;
+      let currentConference;
       const TestMockChild = createMockChild(conf => {
-        testConference = conf;
+        currentConference = conf;
       });
 
       const { container } = render(
@@ -2760,13 +2754,13 @@ describe('AntMedia Component', () => {
       });
 
       const mockUrl = 'data:image/png;base64,example';
-      testConference.setVirtualBackgroundImage(mockUrl);
+      currentConference.setVirtualBackgroundImage(mockUrl);
     });
 
     it('fetches the image as a blob and calls setAndEnableVirtualBackgroundImage if the URL does not start with "data:image"', async () => {
-      let testConference;
+      let currentConference;
       const TestMockChild = createMockChild(conf => {
-        testConference = conf;
+        currentConference = conf;
       });
 
       const { container } = render(
@@ -2787,17 +2781,17 @@ describe('AntMedia Component', () => {
         blob: jest.fn().mockResolvedValue(new Blob(['image content'], { type: 'image/png' })),
       });
       global.URL.createObjectURL = jest.fn().mockReturnValue(mockBlobUrl);
-      testConference.setAndEnableVirtualBackgroundImage = jest.fn();
-      await testConference.setVirtualBackgroundImage(mockUrl);
+      currentConference.setAndEnableVirtualBackgroundImage = jest.fn();
+      await currentConference.setVirtualBackgroundImage(mockUrl);
       expect(global.fetch).toHaveBeenCalledWith(mockUrl);
     });
   });
 
   describe('handleBackgroundReplacement', () => {
     it('disables video effect when option is "none"', async () => {
-      let testConference;
+      let currentConference;
       const TestMockChild = createMockChild(conf => {
-        testConference = conf;
+        currentConference = conf;
       });
 
       const { container } = render(
@@ -2812,16 +2806,16 @@ describe('AntMedia Component', () => {
         expect(webRTCAdaptorConstructor).not.toBe(undefined);
       });
 
-      testConference.setIsVideoEffectRunning = jest.fn();
+      currentConference.setIsVideoEffectRunning = jest.fn();
 
-      testConference.handleBackgroundReplacement("none");
-      expect(testConference.setIsVideoEffectRunning).not.toHaveBeenCalled();
+      currentConference.handleBackgroundReplacement("none");
+      expect(currentConference.setIsVideoEffectRunning).not.toHaveBeenCalled();
     });
 
     it('enables slight blur effect when option is "slight-blur"', async () => {
-      let testConference;
+      let currentConference;
       const TestMockChild = createMockChild(conf => {
-        testConference = conf;
+        currentConference = conf;
       });
 
       const { container } = render(
@@ -2836,16 +2830,16 @@ describe('AntMedia Component', () => {
         expect(webRTCAdaptorConstructor).not.toBe(undefined);
       });
 
-      testConference.setIsVideoEffectRunning = jest.fn();
+      currentConference.setIsVideoEffectRunning = jest.fn();
 
-      testConference.handleBackgroundReplacement("slight-blur");
-      expect(testConference.setIsVideoEffectRunning).not.toHaveBeenCalled();
+      currentConference.handleBackgroundReplacement("slight-blur");
+      expect(currentConference.setIsVideoEffectRunning).not.toHaveBeenCalled();
     });
 
     it('enables blur effect when option is "blur"', async () => {
-      let testConference;
+      let currentConference;
       const TestMockChild = createMockChild(conf => {
-        testConference = conf;
+        currentConference = conf;
       });
 
       const { container } = render(
@@ -2860,16 +2854,16 @@ describe('AntMedia Component', () => {
         expect(webRTCAdaptorConstructor).not.toBe(undefined);
       });
 
-      testConference.setIsVideoEffectRunning = jest.fn();
+      currentConference.setIsVideoEffectRunning = jest.fn();
 
-      testConference.handleBackgroundReplacement("blur");
-      expect(testConference.setIsVideoEffectRunning).not.toHaveBeenCalled();
+      currentConference.handleBackgroundReplacement("blur");
+      expect(currentConference.setIsVideoEffectRunning).not.toHaveBeenCalled();
     });
 
     it('enables virtual background effect when option is "background" and virtualBackground is not null', async () => {
-      let testConference;
+      let currentConference;
       const TestMockChild = createMockChild(conf => {
-        testConference = conf;
+        currentConference = conf;
       });
 
       const { container } = render(
@@ -2884,18 +2878,18 @@ describe('AntMedia Component', () => {
         expect(webRTCAdaptorConstructor).not.toBe(undefined);
       });
 
-      testConference.setIsVideoEffectRunning = jest.fn();
+      currentConference.setIsVideoEffectRunning = jest.fn();
 
       process.env.REACT_APP_VIRTUAL_BACKGROUND_IMAGES = "http://example.com/image.png";
 
-      testConference.handleBackgroundReplacement("background");
-      expect(testConference.setIsVideoEffectRunning).not.toHaveBeenCalled();
+      currentConference.handleBackgroundReplacement("background");
+      expect(currentConference.setIsVideoEffectRunning).not.toHaveBeenCalled();
     });
 
     it('sets and enables virtual background image when option is "background" and virtualBackground is null', async () => {
-      let testConference;
+      let currentConference;
       const TestMockChild = createMockChild(conf => {
-        testConference = conf;
+        currentConference = conf;
       });
 
       const { container } = render(
@@ -2912,18 +2906,18 @@ describe('AntMedia Component', () => {
 
       process.env.REACT_APP_VIRTUAL_BACKGROUND_IMAGES = null;
 
-      testConference.setAndEnableVirtualBackgroundImage = jest.fn();
+      currentConference.setAndEnableVirtualBackgroundImage = jest.fn();
 
-      await testConference.handleBackgroundReplacement("background");
+      await currentConference.handleBackgroundReplacement("background");
       await waitFor(() => {
-        expect(testConference.setAndEnableVirtualBackgroundImage).not.toHaveBeenCalled();
+        expect(currentConference.setAndEnableVirtualBackgroundImage).not.toHaveBeenCalled();
       });
     });
 
     it('handles error when enabling effect fails', async () => {
-      let testConference;
+      let currentConference;
       const TestMockChild = createMockChild(conf => {
-        testConference = conf;
+        currentConference = conf;
       });
 
       const { container } = render(
@@ -2938,20 +2932,20 @@ describe('AntMedia Component', () => {
         expect(webRTCAdaptorConstructor).not.toBe(undefined);
       });
 
-      testConference.enableEffect = jest.fn()
+      currentConference.enableEffect = jest.fn()
 
-      testConference.enableEffect.mockRejectedValue(new Error('Effect enable failed')); // Mock failure
+      currentConference.enableEffect.mockRejectedValue(new Error('Effect enable failed')); // Mock failure
 
-      await testConference.handleBackgroundReplacement("blur");
+      await currentConference.handleBackgroundReplacement("blur");
     });
 
   });
 
   describe('checkAndUpdateVideoAudioSourcesForPublishSpeedTest', () => {
     it('selects the first available camera if the selected camera is not available', async () => {
-      let testConference;
+      let currentConference;
       const TestMockChild = createMockChild(conf => {
-        testConference = conf;
+        currentConference = conf;
       });
 
       const { container } = render(
@@ -2973,19 +2967,19 @@ describe('AntMedia Component', () => {
       const mockSelectedDevices = { videoDeviceId: 'camera2', audioDeviceId: 'microphone1' };
       const mockSetSelectedDevices = jest.fn();
 
-      testConference.devices = mockDevices;
-      testConference.getSelectedDevices = jest.fn().mockReturnValue(mockSelectedDevices);
-      testConference.setSelectedDevices = mockSetSelectedDevices;
+      currentConference.devices = mockDevices;
+      currentConference.getSelectedDevices = jest.fn().mockReturnValue(mockSelectedDevices);
+      currentConference.setSelectedDevices = mockSetSelectedDevices;
 
-      testConference.checkAndUpdateVideoAudioSourcesForPublishSpeedTest();
+      currentConference.checkAndUpdateVideoAudioSourcesForPublishSpeedTest();
 
       //expect(mockSetSelectedDevices).toHaveBeenCalledWith({ videoDeviceId: 'camera1', audioDeviceId: 'microphone1' });
     });
 
     it('selects the first available microphone if the selected microphone is not available', async () => {
-      let testConference;
+      let currentConference;
       const TestMockChild = createMockChild(conf => {
-        testConference = conf;
+        currentConference = conf;
       });
 
       const { container } = render(
@@ -3007,19 +3001,19 @@ describe('AntMedia Component', () => {
       const mockSelectedDevices = { videoDeviceId: 'camera1', audioDeviceId: 'microphone2' };
       const mockSetSelectedDevices = jest.fn();
 
-      testConference.devices = mockDevices;
-      testConference.getSelectedDevices = jest.fn().mockReturnValue(mockSelectedDevices);
-      testConference.setSelectedDevices = mockSetSelectedDevices;
+      currentConference.devices = mockDevices;
+      currentConference.getSelectedDevices = jest.fn().mockReturnValue(mockSelectedDevices);
+      currentConference.setSelectedDevices = mockSetSelectedDevices;
 
-      testConference.checkAndUpdateVideoAudioSourcesForPublishSpeedTest();
+      currentConference.checkAndUpdateVideoAudioSourcesForPublishSpeedTest();
 
       //expect(mockSetSelectedDevices).toHaveBeenCalledWith({ videoDeviceId: 'camera1', audioDeviceId: 'microphone1' });
     });
 
     it('does not change selected devices if they are available', async () => {
-      let testConference;
+      let currentConference;
       const TestMockChild = createMockChild(conf => {
-        testConference = conf;
+        currentConference = conf;
       });
 
       const { container } = render(
@@ -3041,19 +3035,19 @@ describe('AntMedia Component', () => {
       const mockSelectedDevices = { videoDeviceId: 'camera1', audioDeviceId: 'microphone1' };
       const mockSetSelectedDevices = jest.fn();
 
-      testConference.devices = mockDevices;
-      testConference.getSelectedDevices = jest.fn().mockReturnValue(mockSelectedDevices);
-      testConference.setSelectedDevices = mockSetSelectedDevices;
+      currentConference.devices = mockDevices;
+      currentConference.getSelectedDevices = jest.fn().mockReturnValue(mockSelectedDevices);
+      currentConference.setSelectedDevices = mockSetSelectedDevices;
 
-      testConference.checkAndUpdateVideoAudioSourcesForPublishSpeedTest();
+      currentConference.checkAndUpdateVideoAudioSourcesForPublishSpeedTest();
 
       //expect(mockSetSelectedDevices).toHaveBeenCalledWith(mockSelectedDevices);
     });
 
     it('switches video camera capture if the selected camera changes', async () => {
-      let testConference;
+      let currentConference;
       const TestMockChild = createMockChild(conf => {
-        testConference = conf;
+        currentConference = conf;
       });
 
       const { container } = render(
@@ -3072,21 +3066,21 @@ describe('AntMedia Component', () => {
       const mockSetSelectedDevices = jest.fn();
       const mockSwitchVideoCameraCapture = jest.fn();
 
-      testConference.devices = [{ kind: 'videoinput', deviceId: 'camera1' }];
-      testConference.getSelectedDevices = jest.fn().mockReturnValue(mockSelectedDevices);
-      testConference.setSelectedDevices = mockSetSelectedDevices;
-      testConference.speedTestForPublishWebRtcAdaptor = { current: { switchVideoCameraCapture: mockSwitchVideoCameraCapture } };
-      testConference.publishStreamId = 'stream1';
+      currentConference.devices = [{ kind: 'videoinput', deviceId: 'camera1' }];
+      currentConference.getSelectedDevices = jest.fn().mockReturnValue(mockSelectedDevices);
+      currentConference.setSelectedDevices = mockSetSelectedDevices;
+      currentConference.speedTestForPublishWebRtcAdaptor = { current: { switchVideoCameraCapture: mockSwitchVideoCameraCapture } };
+      currentConference.publishStreamId = 'stream1';
 
-      testConference.checkAndUpdateVideoAudioSourcesForPublishSpeedTest();
+      currentConference.checkAndUpdateVideoAudioSourcesForPublishSpeedTest();
 
       //expect(mockSwitchVideoCameraCapture).toHaveBeenCalledWith('stream1', 'camera1');
     });
 
     it('switches audio input source if the selected microphone changes', async () => {
-      let testConference;
+      let currentConference;
       const TestMockChild = createMockChild(conf => {
-        testConference = conf;
+        currentConference = conf;
       });
 
       const { container } = render(
@@ -3105,21 +3099,21 @@ describe('AntMedia Component', () => {
       const mockSetSelectedDevices = jest.fn();
       const mockSwitchAudioInputSource = jest.fn();
 
-      testConference.devices = [{ kind: 'audioinput', deviceId: 'microphone1' }];
-      testConference.getSelectedDevices = jest.fn().mockReturnValue(mockSelectedDevices);
-      testConference.setSelectedDevices = mockSetSelectedDevices;
-      testConference.speedTestForPublishWebRtcAdaptor = { current: { switchAudioInputSource: mockSwitchAudioInputSource } };
-      testConference.publishStreamId = 'stream1';
+      currentConference.devices = [{ kind: 'audioinput', deviceId: 'microphone1' }];
+      currentConference.getSelectedDevices = jest.fn().mockReturnValue(mockSelectedDevices);
+      currentConference.setSelectedDevices = mockSetSelectedDevices;
+      currentConference.speedTestForPublishWebRtcAdaptor = { current: { switchAudioInputSource: mockSwitchAudioInputSource } };
+      currentConference.publishStreamId = 'stream1';
 
-      testConference.checkAndUpdateVideoAudioSourcesForPublishSpeedTest();
+      currentConference.checkAndUpdateVideoAudioSourcesForPublishSpeedTest();
 
       //expect(mockSwitchAudioInputSource).toHaveBeenCalledWith('stream1', 'microphone1');
     });
 
     it('handles errors when switching video and audio sources', async () => {
-      let testConference;
+      let currentConference;
       const TestMockChild = createMockChild(conf => {
-        testConference = conf;
+        currentConference = conf;
       });
 
       const { container } = render(
@@ -3140,21 +3134,21 @@ describe('AntMedia Component', () => {
       const mockSwitchAudioInputSource = jest.fn().mockImplementation(() => { throw new Error('Error switching audio'); });
       const mockConsoleError = jest.spyOn(console, 'error').mockImplementation();
 
-      testConference.devices = [{ kind: 'videoinput', deviceId: 'camera1' }, { kind: 'audioinput', deviceId: 'microphone1' }];
-      testConference.getSelectedDevices = jest.fn().mockReturnValue(mockSelectedDevices);
-      testConference.setSelectedDevices = mockSetSelectedDevices;
-      testConference.speedTestForPublishWebRtcAdaptor = { current: { switchVideoCameraCapture: mockSwitchVideoCameraCapture, switchAudioInputSource: mockSwitchAudioInputSource } };
-      testConference.publishStreamId = 'stream1';
+      currentConference.devices = [{ kind: 'videoinput', deviceId: 'camera1' }, { kind: 'audioinput', deviceId: 'microphone1' }];
+      currentConference.getSelectedDevices = jest.fn().mockReturnValue(mockSelectedDevices);
+      currentConference.setSelectedDevices = mockSetSelectedDevices;
+      currentConference.speedTestForPublishWebRtcAdaptor = { current: { switchVideoCameraCapture: mockSwitchVideoCameraCapture, switchAudioInputSource: mockSwitchAudioInputSource } };
+      currentConference.publishStreamId = 'stream1';
 
-      testConference.checkAndUpdateVideoAudioSourcesForPublishSpeedTest();
+      currentConference.checkAndUpdateVideoAudioSourcesForPublishSpeedTest();
 
       //expect(mockConsoleError).toHaveBeenCalledWith('Error while switching video and audio sources for the publish speed test adaptor', expect.any(Error));
     });
 
     it('handles errors when switching video and audio source', async () => {
-      let testConference;
+      let currentConference;
       const TestMockChild = createMockChild(conf => {
-        testConference = conf;
+        currentConference = conf;
       });
 
       mediaDevicesMock.enumerateDevices.mockResolvedValue([
@@ -3174,7 +3168,7 @@ describe('AntMedia Component', () => {
       });
 
       await act(async () => {
-        testConference.startSpeedTest();
+        currentConference.startSpeedTest();
       });
 
       await waitFor(() => {
@@ -3198,15 +3192,15 @@ describe('AntMedia Component', () => {
       });
       const mockConsoleError = jest.spyOn(console, 'error').mockImplementation();
 
-      testConference.devices = [{kind: 'videoinput', deviceId: 'camera1'}, {kind: 'audioinput', deviceId: 'microphone1'}];
-      testConference.getSelectedDevices = jest.fn().mockReturnValue(mockSelectedDevices);
-      testConference.setSelectedDevices = mockSetSelectedDevices;
-      testConference.speedTestForPublishWebRtcAdaptor = {current: {switchVideoCameraCapture: mockSwitchVideoCameraCapture, switchAudioInputSource: mockSwitchAudioInputSource}};
-      testConference.switchVideoCameraCapture = mockSwitchVideoCameraCapture;
-      testConference.publishStreamId = 'stream1';
+      currentConference.devices = [{kind: 'videoinput', deviceId: 'camera1'}, {kind: 'audioinput', deviceId: 'microphone1'}];
+      currentConference.getSelectedDevices = jest.fn().mockReturnValue(mockSelectedDevices);
+      currentConference.setSelectedDevices = mockSetSelectedDevices;
+      currentConference.speedTestForPublishWebRtcAdaptor = {current: {switchVideoCameraCapture: mockSwitchVideoCameraCapture, switchAudioInputSource: mockSwitchAudioInputSource}};
+      currentConference.switchVideoCameraCapture = mockSwitchVideoCameraCapture;
+      currentConference.publishStreamId = 'stream1';
 
       await act(async () => {
-        testConference.checkAndUpdateVideoAudioSourcesForPublishSpeedTest();
+        currentConference.checkAndUpdateVideoAudioSourcesForPublishSpeedTest();
       });
       mockConsoleError.mockRestore();
     });
@@ -3214,9 +3208,9 @@ describe('AntMedia Component', () => {
 
   describe('checkVideoTrackHealth', () => {
     it('returns true if the camera is turned off by the user', async () => {
-      let testConference;
+      let currentConference;
       const TestMockChild = createMockChild(conf => {
-        testConference = conf;
+        currentConference = conf;
       });
 
       render(
@@ -3231,11 +3225,11 @@ describe('AntMedia Component', () => {
         expect(webRTCAdaptorConstructor).not.toBe(undefined);
       });
 
-      testConference.setIsMyCamTurnedOff(true);
+      currentConference.setIsMyCamTurnedOff(true);
       await waitFor(() => {
-        expect(testConference.isMyCamTurnedOff).toBe(true);
+        expect(currentConference.isMyCamTurnedOff).toBe(true);
       });
-      testConference.mediaManager = {
+      currentConference.mediaManager = {
         localStream: {
           getAudioTracks: jest.fn().mockReturnValue([]),
           getVideoTracks: jest.fn().mockReturnValue([
@@ -3243,13 +3237,13 @@ describe('AntMedia Component', () => {
           ]),
         }
       };
-      expect(testConference.checkVideoTrackHealth()).toBe(true);
+      expect(currentConference.checkVideoTrackHealth()).toBe(true);
     });
 
     it('returns false if the camera is turned on and the video track is not muted', async () => {
-      let testConference;
+      let currentConference;
       const TestMockChild = createMockChild(conf => {
-        testConference = conf;
+        currentConference = conf;
       });
 
       render(
@@ -3264,12 +3258,12 @@ describe('AntMedia Component', () => {
         expect(webRTCAdaptorConstructor).not.toBe(undefined);
       });
 
-      testConference.setIsMyCamTurnedOff(false);
+      currentConference.setIsMyCamTurnedOff(false);
       await waitFor(() => {
-        expect(testConference.isMyCamTurnedOff).toBe(false);
+        expect(currentConference.isMyCamTurnedOff).toBe(false);
       });      
 
-      testConference.mediaManager = {
+      currentConference.mediaManager = {
         localStream: {
           getAudioTracks: jest.fn().mockReturnValue([]),
           getVideoTracks: jest.fn().mockReturnValue([
@@ -3277,14 +3271,14 @@ describe('AntMedia Component', () => {
           ]),
         }
       };
-      expect(testConference.checkVideoTrackHealth()).toBe(false);
+      expect(currentConference.checkVideoTrackHealth()).toBe(false);
     });
   });
 
   it('sets and fills play stats list correctly', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     const mockStats = {
@@ -3312,25 +3306,25 @@ describe('AntMedia Component', () => {
     });
 
     await act(async () => {
-      testConference.setAndFillPlayStatsList(mockStats);
-    });
-
-    expect(testConference.statsList.current.currentRoundTripTime).not.toBe(100);
-    expect(testConference.statsList.current.packetsReceived).not.toBe(200);
-    expect(testConference.statsList.current.totalBytesReceivedCount).not.toBe(300);
-    expect(testConference.statsList.current.framesReceived).not.toBe(400);
-    expect(testConference.statsList.current.framesDropped).not.toBe(500);
-    expect(testConference.statsList.current.startTime).not.toBe(600);
-    expect(testConference.statsList.current.currentTimestamp).not.toBe(700);
-    expect(testConference.statsList.current.firstBytesReceivedCount).not.toBe(800);
-    expect(testConference.statsList.current.lastBytesReceived).not.toBe(900);
-    expect(testConference.statsList.current.videoPacketsLost).not.toBe(1000);
+      currentConference.setAndFillPlayStatsList(mockStats);
+    });
+
+    expect(currentConference.statsList.current.currentRoundTripTime).not.toBe(100);
+    expect(currentConference.statsList.current.packetsReceived).not.toBe(200);
+    expect(currentConference.statsList.current.totalBytesReceivedCount).not.toBe(300);
+    expect(currentConference.statsList.current.framesReceived).not.toBe(400);
+    expect(currentConference.statsList.current.framesDropped).not.toBe(500);
+    expect(currentConference.statsList.current.startTime).not.toBe(600);
+    expect(currentConference.statsList.current.currentTimestamp).not.toBe(700);
+    expect(currentConference.statsList.current.firstBytesReceivedCount).not.toBe(800);
+    expect(currentConference.statsList.current.lastBytesReceived).not.toBe(900);
+    expect(currentConference.statsList.current.videoPacketsLost).not.toBe(1000);
   });
 
   it('sets and fills publish stats list correctly', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     const mockStats = {
@@ -3357,27 +3351,27 @@ describe('AntMedia Component', () => {
     });
 
     await act(async () => {
-      testConference.setAndFillPublishStatsList(mockStats);
+      currentConference.setAndFillPublishStatsList(mockStats);
     });
 
     await waitFor(() => {
-      expect(testConference.statsList.current.videoRoundTripTime).not.toBe(100);
-      expect(testConference.statsList.current.audioRoundTripTime).not.toBe(200);
-      expect(testConference.statsList.current.videoPacketsLost).not.toBe(300);
-      expect(testConference.statsList.current.totalVideoPacketsSent).not.toBe(400);
-      expect(testConference.statsList.current.totalAudioPacketsSent).not.toBe(500);
-      expect(testConference.statsList.current.audioPacketsLost).not.toBe(600);
-      expect(testConference.statsList.current.videoJitter).not.toBe(700);
-      expect(testConference.statsList.current.audioJitter).not.toBe(800);
-      expect(testConference.statsList.current.currentOutgoingBitrate).not.toBe(900);
+      expect(currentConference.statsList.current.videoRoundTripTime).not.toBe(100);
+      expect(currentConference.statsList.current.audioRoundTripTime).not.toBe(200);
+      expect(currentConference.statsList.current.videoPacketsLost).not.toBe(300);
+      expect(currentConference.statsList.current.totalVideoPacketsSent).not.toBe(400);
+      expect(currentConference.statsList.current.totalAudioPacketsSent).not.toBe(500);
+      expect(currentConference.statsList.current.audioPacketsLost).not.toBe(600);
+      expect(currentConference.statsList.current.videoJitter).not.toBe(700);
+      expect(currentConference.statsList.current.audioJitter).not.toBe(800);
+      expect(currentConference.statsList.current.currentOutgoingBitrate).not.toBe(900);
     });
   });
 
   it('sets speed test object to failed state', async () => {
     // Create a local reference for this test
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
     
     const {container} = render(
@@ -3391,7 +3385,7 @@ describe('AntMedia Component', () => {
       expect(webRTCAdaptorConstructor).not.toBe(undefined);
     });
 
-    testConference.speedTestObject = {
+    currentConference.speedTestObject = {
       message: "Speed Test",
       isfinished: false,
       isfailed: false,
@@ -3399,25 +3393,25 @@ describe('AntMedia Component', () => {
       progressValue: 50
     };
 
-    testConference.setSpeedTestObject = jest.fn();
+    currentConference.setSpeedTestObject = jest.fn();
 
     await act(async () => {
-      testConference.setSpeedTestObjectFailed('Error message');
+      currentConference.setSpeedTestObjectFailed('Error message');
     });
 
     await waitFor(() => {
-      expect(testConference.speedTestObject.message).toBe('Error message');
-      expect(testConference.speedTestObject.isfinished).toBe(false);
-      expect(testConference.speedTestObject.isfailed).toBe(true);
-      expect(testConference.speedTestObject.errorMessage).toBe('Error message');
-      expect(testConference.speedTestObject.progressValue).toBe(0);
+      expect(currentConference.speedTestObject.message).toBe('Error message');
+      expect(currentConference.speedTestObject.isfinished).toBe(false);
+      expect(currentConference.speedTestObject.isfailed).toBe(true);
+      expect(currentConference.speedTestObject.errorMessage).toBe('Error message');
+      expect(currentConference.speedTestObject.progressValue).toBe(0);
     });
   });
 
   it('sets speed test object progress correctly', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     const {container} = render(
@@ -3432,21 +3426,21 @@ describe('AntMedia Component', () => {
     });
 
     await act(async () => {
-      testConference.setSpeedTestObjectProgress(50);
+      currentConference.setSpeedTestObjectProgress(50);
     });
 
     await waitFor(() => {
-      expect(testConference.speedTestObject.isfinished).toBe(false);
-      expect(testConference.speedTestObject.isfailed).toBe(false);
-      expect(testConference.speedTestObject.errorMessage).toBe('');
-      expect(testConference.speedTestObject.progressValue).toBe(50);
+      expect(currentConference.speedTestObject.isfinished).toBe(false);
+      expect(currentConference.speedTestObject.isfailed).toBe(false);
+      expect(currentConference.speedTestObject.errorMessage).toBe('');
+      expect(currentConference.speedTestObject.progressValue).toBe(50);
     });
   });
 
   it('handles progress value greater than 100', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     const {container} = render(
@@ -3461,22 +3455,22 @@ describe('AntMedia Component', () => {
     });
 
     await act(async () => {
-      testConference.setSpeedTestObjectProgress(150);
+      currentConference.setSpeedTestObjectProgress(150);
     });
 
     const stopSpeedTest = jest.fn();
     //expect(stopSpeedTest).toHaveBeenCalled();
-    expect(testConference.speedTestObject.message).toBe('Speed test failed. It may be due to firewall, wi-fi or network restrictions. Change your network or Try again ');
-    expect(testConference.speedTestObject.isfinished).toBe(false);
-    expect(testConference.speedTestObject.isfailed).toBe(true);
-    expect(testConference.speedTestObject.errorMessage).toBe('Speed test failed. It may be due to firewall, wi-fi or network restrictions. Change your network or Try again ');
-    expect(testConference.speedTestObject.progressValue).toBe(0);
+    expect(currentConference.speedTestObject.message).toBe('Speed test failed. It may be due to firewall, wi-fi or network restrictions. Change your network or Try again ');
+    expect(currentConference.speedTestObject.isfinished).toBe(false);
+    expect(currentConference.speedTestObject.isfailed).toBe(true);
+    expect(currentConference.speedTestObject.errorMessage).toBe('Speed test failed. It may be due to firewall, wi-fi or network restrictions. Change your network or Try again ');
+    expect(currentConference.speedTestObject.progressValue).toBe(0);
   });
 
   it('calculates play speed test result with great connection', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     const {container} = render(
@@ -3490,7 +3484,7 @@ describe('AntMedia Component', () => {
       expect(webRTCAdaptorConstructor).not.toBe(undefined);
     });
 
-    testConference.statsList.current = [
+    currentConference.statsList.current = [
       {
         totalBytesReceivedCount: 1000,
         framesReceived: 100,
@@ -3530,19 +3524,19 @@ describe('AntMedia Component', () => {
     ];
 
     await act(async () => {
-      testConference.calculateThePlaySpeedTestResult();
+      currentConference.calculateThePlaySpeedTestResult();
     });
 
-    expect(testConference.speedTestObject.message).toBe('Your connection is Great!');
-    expect(testConference.speedTestObject.isfailed).toBe(false);
-    expect(testConference.speedTestObject.progressValue).toBe(100);
-    expect(testConference.speedTestObject.isfinished).toBe(true);
+    expect(currentConference.speedTestObject.message).toBe('Your connection is Great!');
+    expect(currentConference.speedTestObject.isfailed).toBe(false);
+    expect(currentConference.speedTestObject.progressValue).toBe(100);
+    expect(currentConference.speedTestObject.isfinished).toBe(true);
   });
 
   it('calculates play speed test result with moderate connection', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     const {container} = render(
@@ -3556,7 +3550,7 @@ describe('AntMedia Component', () => {
       expect(webRTCAdaptorConstructor).not.toBe(undefined);
     });
 
-    testConference.statsList.current = [
+    currentConference.statsList.current = [
       {
         totalBytesReceivedCount: 1000,
         framesReceived: 100,
@@ -3596,19 +3590,19 @@ describe('AntMedia Component', () => {
     ];
 
     await act(async () => {
-      testConference.calculateThePlaySpeedTestResult();
+      currentConference.calculateThePlaySpeedTestResult();
     });
 
-    expect(testConference.speedTestObject.message).toBe('Your connection is moderate, occasional disruptions may occur');
-    expect(testConference.speedTestObject.isfailed).toBe(false);
-    expect(testConference.speedTestObject.progressValue).toBe(100);
-    expect(testConference.speedTestObject.isfinished).toBe(true);
+    expect(currentConference.speedTestObject.message).toBe('Your connection is moderate, occasional disruptions may occur');
+    expect(currentConference.speedTestObject.isfailed).toBe(false);
+    expect(currentConference.speedTestObject.progressValue).toBe(100);
+    expect(currentConference.speedTestObject.isfinished).toBe(true);
   });
 
   it('calculates play speed test result with poor connection', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     const {container} = render(
@@ -3622,7 +3616,7 @@ describe('AntMedia Component', () => {
       expect(webRTCAdaptorConstructor).not.toBe(undefined);
     });
 
-    testConference.statsList.current = [
+    currentConference.statsList.current = [
       {
         totalBytesReceivedCount: 1000,
         framesReceived: 100,
@@ -3662,19 +3656,19 @@ describe('AntMedia Component', () => {
     ];
 
     await act(async () => {
-      testConference.calculateThePlaySpeedTestResult();
+      currentConference.calculateThePlaySpeedTestResult();
     });
 
-    expect(testConference.speedTestObject.message).toBe('Your connection quality is poor. You may experience interruptions');
-    expect(testConference.speedTestObject.isfailed).toBe(false);
-    expect(testConference.speedTestObject.progressValue).toBe(100);
-    expect(testConference.speedTestObject.isfinished).toBe(true);
+    expect(currentConference.speedTestObject.message).toBe('Your connection quality is poor. You may experience interruptions');
+    expect(currentConference.speedTestObject.isfailed).toBe(false);
+    expect(currentConference.speedTestObject.progressValue).toBe(100);
+    expect(currentConference.speedTestObject.isfinished).toBe(true);
   });
 
   it('updates progress and stats list on subsequent iterations', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     const {container} = render(
@@ -3688,22 +3682,22 @@ describe('AntMedia Component', () => {
       expect(webRTCAdaptorConstructor).not.toBe(undefined);
     });
 
-    testConference.speedTestCounter.current = 1;
-    testConference.statsList.current = [{}, {}];
-    testConference.setAndFillPlayStatsList = jest.fn();
-    testConference.setSpeedTestObjectProgress = jest.fn();
-    testConference.setSpeedTestObject = jest.fn();
+    currentConference.speedTestCounter.current = 1;
+    currentConference.statsList.current = [{}, {}];
+    currentConference.setAndFillPlayStatsList = jest.fn();
+    currentConference.setSpeedTestObjectProgress = jest.fn();
+    currentConference.setSpeedTestObject = jest.fn();
 
-    testConference.processUpdatedStatsForPlaySpeedTest({});
+    currentConference.processUpdatedStatsForPlaySpeedTest({});
 
-    expect(testConference.statsList.current).toEqual([{}, {}, {}]);
+    expect(currentConference.statsList.current).toEqual([{}, {}, {}]);
   });
 
   it('updates speed test object progress when iterations are insufficient', async () => {
     // Create a local reference for this test
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
     
     const {container} = render(
@@ -3717,11 +3711,11 @@ describe('AntMedia Component', () => {
       expect(webRTCAdaptorConstructor).not.toBe(undefined);
     });
 
-    testConference.speedTestCounter = { current: 2 };
-    testConference.statsList = { current: [{}, {}] };
-    testConference.setSpeedTestObjectProgress = jest.fn();
-    testConference.setSpeedTestObject = jest.fn();
-    testConference.speedTestObject = {
+    currentConference.speedTestCounter = { current: 2 };
+    currentConference.statsList = { current: [{}, {}] };
+    currentConference.setSpeedTestObjectProgress = jest.fn();
+    currentConference.setSpeedTestObject = jest.fn();
+    currentConference.speedTestObject = {
       message: "Speed Test",
       isfinished: false,
       isfailed: false,
@@ -3729,10 +3723,10 @@ describe('AntMedia Component', () => {
       progressValue: 0
     };
 
-    testConference.processUpdatedStatsForPlaySpeedTest({});
+    currentConference.processUpdatedStatsForPlaySpeedTest({});
 
-    expect(testConference.setSpeedTestObject).not.toHaveBeenCalledWith({
-      message: testConference.speedTestObject.message,
+    expect(currentConference.setSpeedTestObject).not.toHaveBeenCalledWith({
+      message: currentConference.speedTestObject.message,
       isfinished: false,
       isfailed: false,
       errorMessage: "",
@@ -3743,9 +3737,9 @@ describe('AntMedia Component', () => {
   describe('loadMoreParticipants', () => {
     it('get subtracks as many as loadingStepSize', async () => {
       // Create a local reference for this test
-      let testConference;
+      let currentConference;
       const TestMockChild = createMockChild(conf => {
-        testConference = conf;
+        currentConference = conf;
       });
       
       const { container } = render(
@@ -3761,24 +3755,24 @@ describe('AntMedia Component', () => {
       });
 
       await act(async () => {
-        testConference.globals.participantListPagination.currentPagePosition = 2;
-        testConference.setParticipantCount(15);
+        currentConference.globals.participantListPagination.currentPagePosition = 2;
+        currentConference.setParticipantCount(15);
       });
 
       await waitFor(() => {
-        expect(testConference.participantCount).toBe(15);
+        expect(currentConference.participantCount).toBe(15);
       });
       
-      testConference.loadMoreParticipants();
+      currentConference.loadMoreParticipants();
 
-      expect(webRTCAdaptorConstructor.getSubtracks).toHaveBeenCalledWith("room", null, 2, testConference.globals.participantListPagination.loadingStepSize);
+      expect(webRTCAdaptorConstructor.getSubtracks).toHaveBeenCalledWith("room", null, 2, currentConference.globals.participantListPagination.loadingStepSize);
     });
 
 
     it('get subtracks as many as difference', async () => {
-      let testConference;
+      let currentConference;
       const TestMockChild = createMockChild(conf => {
-        testConference = conf;
+        currentConference = conf;
       });
 
       const { container } = render(
@@ -3794,15 +3788,15 @@ describe('AntMedia Component', () => {
       });
 
       await act(async () => {
-        testConference.globals.participantListPagination.currentPagePosition = 2;
-        testConference.setParticipantCount(5);
+        currentConference.globals.participantListPagination.currentPagePosition = 2;
+        currentConference.setParticipantCount(5);
       });
 
       await waitFor(() => {
-        expect(testConference.participantCount).toBe(5);
+        expect(currentConference.participantCount).toBe(5);
       });
       
-      testConference.loadMoreParticipants();
+      currentConference.loadMoreParticipants();
 
       expect(webRTCAdaptorConstructor.getSubtracks).toHaveBeenCalledWith("room", null, 2, 3);
     });
@@ -3810,9 +3804,9 @@ describe('AntMedia Component', () => {
     
 
     it('update participant count, when we receive new subtrack count', async () => {
-      let testConference;
+      let currentConference;
       const TestMockChild = createMockChild(conf => {
-        testConference = conf;
+        currentConference = conf;
       });
 
       const { container } = render(
@@ -3834,15 +3828,15 @@ describe('AntMedia Component', () => {
       });
 
       await waitFor(() => {
-        expect(testConference.participantCount).toBe(12);
+        expect(currentConference.participantCount).toBe(12);
       });
     });
   });
 
   it('opens publisher request list drawer and closes other drawers', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     const {container} = render(
@@ -3856,22 +3850,22 @@ describe('AntMedia Component', () => {
       expect(webRTCAdaptorConstructor).not.toBe(undefined);
     });
 
-    testConference.setPublisherRequestListDrawerOpen = jest.fn();
-    testConference.setMessageDrawerOpen = jest.fn();
-    testConference.setParticipantListDrawerOpen = jest.fn();
-    testConference.setEffectsDrawerOpen = jest.fn();
+    currentConference.setPublisherRequestListDrawerOpen = jest.fn();
+    currentConference.setMessageDrawerOpen = jest.fn();
+    currentConference.setParticipantListDrawerOpen = jest.fn();
+    currentConference.setEffectsDrawerOpen = jest.fn();
 
-    testConference.handlePublisherRequestListOpen(true);
-    expect(testConference.setPublisherRequestListDrawerOpen).not.toHaveBeenCalledWith(true);
-    expect(testConference.setMessageDrawerOpen).not.toHaveBeenCalledWith(false);
-    expect(testConference.setParticipantListDrawerOpen).not.toHaveBeenCalledWith(false);
-    expect(testConference.setEffectsDrawerOpen).not.toHaveBeenCalledWith(false);
+    currentConference.handlePublisherRequestListOpen(true);
+    expect(currentConference.setPublisherRequestListDrawerOpen).not.toHaveBeenCalledWith(true);
+    expect(currentConference.setMessageDrawerOpen).not.toHaveBeenCalledWith(false);
+    expect(currentConference.setParticipantListDrawerOpen).not.toHaveBeenCalledWith(false);
+    expect(currentConference.setEffectsDrawerOpen).not.toHaveBeenCalledWith(false);
   });
 
   it('does not send publisher request if not in play only mode', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     const {container} = render(
@@ -3885,18 +3879,18 @@ describe('AntMedia Component', () => {
       expect(webRTCAdaptorConstructor).not.toBe(undefined);
     });
 
-    testConference.handleSendNotificationEvent = jest.fn();
+    currentConference.handleSendNotificationEvent = jest.fn();
     await act(async () => {
-      testConference.setIsPlayOnly(false);
+      currentConference.setIsPlayOnly(false);
     });
-    testConference.handlePublisherRequest();
-    expect(testConference.handleSendNotificationEvent).not.toHaveBeenCalled();
+    currentConference.handlePublisherRequest();
+    expect(currentConference.handleSendNotificationEvent).not.toHaveBeenCalled();
   });
 
   it('sends publisher request if in play only mode', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     const {container} = render(
@@ -3912,10 +3906,10 @@ describe('AntMedia Component', () => {
 
 
     await act(async () => {
-      testConference.handleSendNotificationEvent = jest.fn();
-      testConference.setIsPlayOnly(true);
+      currentConference.handleSendNotificationEvent = jest.fn();
+      currentConference.setIsPlayOnly(true);
     });
-    testConference.handlePublisherRequest();
+    currentConference.handlePublisherRequest();
   });
 
   /*
@@ -3939,9 +3933,9 @@ describe('AntMedia Component', () => {
    */
 
   it('should not run playOnly effect on initial mount', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
       const { container } = render(
@@ -3963,9 +3957,9 @@ describe('AntMedia Component', () => {
 });
 
   it('should run playOnly effect when isPlayOnly changes after mount', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     const mockLocalStorage = {
@@ -3996,7 +3990,7 @@ describe('AntMedia Component', () => {
     });
 
     await act(async () => {
-      testConference.setIsPlayOnly(true);
+      currentConference.setIsPlayOnly(true);
     });
 
     await waitFor(() => {
@@ -4008,9 +4002,9 @@ describe('AntMedia Component', () => {
   });
 
   it('should clear participants and intervals when isPlayOnly changes', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
       const { rerender } = render(
@@ -4027,25 +4021,25 @@ describe('AntMedia Component', () => {
 
       // Set some initial participants
       await act(async () => {
-        testConference.setVideoTrackAssignments(['track1', 'track2']);
-        testConference.setAllParticipants({ participant1: {}, participant2: {} });
+        currentConference.setVideoTrackAssignments(['track1', 'track2']);
+        currentConference.setAllParticipants({ participant1: {}, participant2: {} });
       });
       
       await act(async () => {
-        testConference.setIsPlayOnly(true);
+        currentConference.setIsPlayOnly(true);
       });
 
       // Verify participants are cleared
       await waitFor(() => {
-          expect(testConference.videoTrackAssignments).toEqual([]);
-          expect(testConference.allParticipants).toEqual({});
+          expect(currentConference.videoTrackAssignments).toEqual([]);
+          expect(currentConference.allParticipants).toEqual({});
       });
   });
 
   it('starts becoming publisher if in play only mode', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     const {container} = render(
@@ -4060,31 +4054,31 @@ describe('AntMedia Component', () => {
     });
 
     await act(async () => {
-      testConference.setIsPlayOnly(true);
+      currentConference.setIsPlayOnly(true);
     });
 
     await act(async () => {
-      testConference.setIsPlayOnly = jest.fn();
-      testConference.setInitialized = jest.fn();
-      testConference.setWaitingOrMeetingRoom = jest.fn();
-      testConference.joinRoom = jest.fn();
+      currentConference.setIsPlayOnly = jest.fn();
+      currentConference.setInitialized = jest.fn();
+      currentConference.setWaitingOrMeetingRoom = jest.fn();
+      currentConference.joinRoom = jest.fn();
     });
 
     await act(async () => {
-      testConference.handleStartBecomePublisher();
+      currentConference.handleStartBecomePublisher();
     });
     await waitFor(() => {
-      expect(testConference.setIsPlayOnly).not.toHaveBeenCalledWith(false);
-      expect(testConference.setInitialized).not.toHaveBeenCalledWith(false);
-      expect(testConference.setWaitingOrMeetingRoom).not.toHaveBeenCalledWith("waiting");
-      expect(testConference.joinRoom).not.toHaveBeenCalledWith(testConference.roomName, testConference.publishStreamId);
+      expect(currentConference.setIsPlayOnly).not.toHaveBeenCalledWith(false);
+      expect(currentConference.setInitialized).not.toHaveBeenCalledWith(false);
+      expect(currentConference.setWaitingOrMeetingRoom).not.toHaveBeenCalledWith("waiting");
+      expect(currentConference.joinRoom).not.toHaveBeenCalledWith(currentConference.roomName, currentConference.publishStreamId);
     });
   });
 
   it('rejects become speaker request', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     const {container} = render(
@@ -4098,18 +4092,18 @@ describe('AntMedia Component', () => {
       expect(webRTCAdaptorConstructor).not.toBe(undefined);
     });
 
-    testConference.handleSendNotificationEvent = jest.fn();
+    currentConference.handleSendNotificationEvent = jest.fn();
     const streamId = 'testStreamId';
-    testConference.rejectBecomeSpeakerRequest(streamId);
-    expect(testConference.handleSendNotificationEvent).not.toHaveBeenCalledWith("REJECT_BECOME_PUBLISHER", testConference.roomName, {
+    currentConference.rejectBecomeSpeakerRequest(streamId);
+    expect(currentConference.handleSendNotificationEvent).not.toHaveBeenCalledWith("REJECT_BECOME_PUBLISHER", currentConference.roomName, {
       senderStreamId: streamId
     });
   });
 
   it('handles REQUEST_BECOME_PUBLISHER event when role is Host', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     const { container } = render(
@@ -4125,7 +4119,7 @@ describe('AntMedia Component', () => {
     });
 
     await act(() => {
-      testConference.setPublishStreamId('testStreamId');
+      currentConference.setPublishStreamId('testStreamId');
     });
 
     const notificationEvent = {
@@ -4139,18 +4133,18 @@ describe('AntMedia Component', () => {
     };
 
     await act(async () => {
-      testConference.handleNotificationEvent(obj);
+      currentConference.handleNotificationEvent(obj);
     });
 
     await waitFor(() => {
-      expect(testConference.requestSpeakerList).not.toContain('testStreamId');
+      expect(currentConference.requestSpeakerList).not.toContain('testStreamId');
     });
   });
 
   it('does not handle REQUEST_BECOME_PUBLISHER event if request already received', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     const { container } = render(
@@ -4166,19 +4160,19 @@ describe('AntMedia Component', () => {
     });
 
     await act(() => {
-      testConference.requestSpeakerList = ['testStreamIdListener'];
+      currentConference.requestSpeakerList = ['testStreamIdListener'];
     });
 
     await act(() => {
-      testConference.setRequestSpeakerList(['testStreamIdListener']);
+      currentConference.setRequestSpeakerList(['testStreamIdListener']);
     });
 
     await act(() => {
-      testConference.setPublishStreamId('testStreamIdHost');
+      currentConference.setPublishStreamId('testStreamIdHost');
     });
 
     await act(() => {
-      testConference.setRole(WebinarRoles.Host);
+      currentConference.setRole(WebinarRoles.Host);
     });
 
     const notificationEvent = {
@@ -4194,7 +4188,7 @@ describe('AntMedia Component', () => {
     const consoleSpy = jest.spyOn(console, 'log').mockImplementation();
 
     await act(async () => {
-      testConference.handleNotificationEvent(obj);
+      currentConference.handleNotificationEvent(obj);
     });
 
     expect(consoleSpy).toHaveBeenCalledWith("Request is already received from ", 'testStreamIdListener');
@@ -4202,9 +4196,9 @@ describe('AntMedia Component', () => {
   });
 
   it('handles MAKE_LISTENER_AGAIN event when role is TempListener', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     const { container } = render(
@@ -4220,7 +4214,7 @@ describe('AntMedia Component', () => {
     });
 
     await act(() => {
-      testConference.setRole(WebinarRoles.TempListener);
+      currentConference.setRole(WebinarRoles.TempListener);
     });
 
     const notificationEvent = {
@@ -4234,18 +4228,18 @@ describe('AntMedia Component', () => {
     };
 
     await act(async () => {
-      testConference.handleNotificationEvent(obj);
+      currentConference.handleNotificationEvent(obj);
     });
 
     await waitFor(() => {
-      expect(testConference.isPlayOnly).toBe(true);
+      expect(currentConference.isPlayOnly).toBe(true);
     });
   });
 
   it('handles APPROVE_BECOME_PUBLISHER event when role is Listener', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     const { container } = render(
@@ -4261,11 +4255,11 @@ describe('AntMedia Component', () => {
     });
 
     await act(() => {
-      testConference.setRole(WebinarRoles.Listener);
+      currentConference.setRole(WebinarRoles.Listener);
     });
 
     await act(() => {
-      testConference.setPublishStreamId('testStreamId');
+      currentConference.setPublishStreamId('testStreamId');
     });
 
     const notificationEvent = {
@@ -4279,18 +4273,18 @@ describe('AntMedia Component', () => {
     };
 
     await act(async () => {
-      testConference.handleNotificationEvent(obj);
+      currentConference.handleNotificationEvent(obj);
     });
 
     await waitFor(() => {
-      expect(testConference.isPlayOnly).toBe(false);
+      expect(currentConference.isPlayOnly).toBe(false);
     });
   });
 
   it('handles REJECT_BECOME_PUBLISHER event when role is Listener', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     const { container } = render(
@@ -4306,11 +4300,11 @@ describe('AntMedia Component', () => {
     });
 
     await act(() => {
-      testConference.setRole(WebinarRoles.Listener);
+      currentConference.setRole(WebinarRoles.Listener);
     });
 
     await act(() => {
-      testConference.setPublishStreamId('testStreamId');
+      currentConference.setPublishStreamId('testStreamId');
     });
 
     const notificationEvent = {
@@ -4324,23 +4318,23 @@ describe('AntMedia Component', () => {
     };
 
     await act(async () => {
-      testConference.showInfoSnackbarWithLatency = jest.fn();
+      currentConference.showInfoSnackbarWithLatency = jest.fn();
     });
 
     await act(async () => {
-      testConference.handleNotificationEvent(obj);
+      currentConference.handleNotificationEvent(obj);
     });
 
     await waitFor(() => {
-      expect(testConference.role).toBe(WebinarRoles.Listener);
+      expect(currentConference.role).toBe(WebinarRoles.Listener);
     });
   });
 
 
   it('test play only participant join room', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     const consoleSpy = jest.spyOn(console, 'log').mockImplementation();
@@ -4355,7 +4349,7 @@ describe('AntMedia Component', () => {
     });
 
     await act(async () => {
-      testConference.setIsPlayOnly(true);
+      currentConference.setIsPlayOnly(true);
     });
 
     await act(async () => {
@@ -4363,16 +4357,16 @@ describe('AntMedia Component', () => {
     });
 
     await waitFor(() => {
-      testConference.joinRoom("room", "publishStreamId");
+      currentConference.joinRoom("room", "publishStreamId");
     });
 
     consoleSpy.mockRestore();
   });
 
   it('test not updating devices unless initialized ', async () => {
-    let testConference;
+    let currentConference;
     const TestMockChild = createMockChild(conf => {
-      testConference = conf;
+      currentConference = conf;
     });
 
     const { container } = render(
@@ -4394,11 +4388,11 @@ describe('AntMedia Component', () => {
     const updateMetaData = jest.spyOn(webRTCAdaptorConstructor, 'updateStreamMetaData').mockImplementation();
 
     await act(async () => {
-      testConference.setInitialized(false);
+      currentConference.setInitialized(false);
     });
 
     await act(async () => {
-      testConference.setDevices(mockDevices);
+      currentConference.setDevices(mockDevices);
     });
 
     jest.useFakeTimers();

From f3f1ccf9522d2b19e7c06b99d42963e0bf8dcdaa Mon Sep 17 00:00:00 2001
From: golgetahir <tahir.golge@gmail.com>
Date: Tue, 4 Mar 2025 14:30:17 +0300
Subject: [PATCH 09/11] Remove debug function

---
 react/src/pages/AntMedia.js | 13 -------------
 1 file changed, 13 deletions(-)

diff --git a/react/src/pages/AntMedia.js b/react/src/pages/AntMedia.js
index dddae2f5..9ea08d4f 100644
--- a/react/src/pages/AntMedia.js
+++ b/react/src/pages/AntMedia.js
@@ -449,19 +449,6 @@ function AntMedia(props) {
     const statsList = React.useRef([]);
     const isFirstRunForPlayOnly = React.useRef(true);
 
-
-    // Added this debug function to catch the getUserMedia calls
-    const debugGetUserMedia = () => {
-        const oldGetUserMedia = navigator.mediaDevices.getUserMedia;
-        navigator.mediaDevices.getUserMedia = function() {
-            console.trace("getUserMedia called");
-            return oldGetUserMedia.apply(this, arguments);
-        };
-    };
-    React.useEffect(() => {
-        debugGetUserMedia();
-    }, []);
-
     // video send resolution for publishing
     // possible values: "auto", "highDefinition", "standartDefinition", "lowDefinition"
     const [videoSendResolution, setVideoSendResolution] = React.useState(localStorage.getItem("videoSendResolution") ? localStorage.getItem("videoSendResolution") : "auto");

From a7b503804d0a420436323e2bb6f0a0680a25467b Mon Sep 17 00:00:00 2001
From: golgetahir <tahir.golge@gmail.com>
Date: Sat, 8 Mar 2025 22:47:42 +0300
Subject: [PATCH 10/11] Carry speed test to a custom hook

---
 react/src/__mocks__/useSpeedTest.js           |  32 ++
 .../src/__tests__/hooks/useSpeedTest.test.js  | 475 +++++++++++++++++
 react/src/__tests__/pages/AntMedia.test.js    | 461 +----------------
 react/src/hooks/useSpeedTest.js               | 476 ++++++++++++++++++
 react/src/pages/AntMedia.js                   | 472 ++---------------
 5 files changed, 1017 insertions(+), 899 deletions(-)
 create mode 100644 react/src/__mocks__/useSpeedTest.js
 create mode 100644 react/src/__tests__/hooks/useSpeedTest.test.js
 create mode 100644 react/src/hooks/useSpeedTest.js

diff --git a/react/src/__mocks__/useSpeedTest.js b/react/src/__mocks__/useSpeedTest.js
new file mode 100644
index 00000000..5f6cb8ab
--- /dev/null
+++ b/react/src/__mocks__/useSpeedTest.js
@@ -0,0 +1,32 @@
+import { useRef } from 'react';
+
+const mockSpeedTestStreamId = useRef('test-stream-id-12345');
+const mockStatsList = useRef([]);
+const mockSpeedTestCounter = useRef(0);
+
+const mockSpeedTestResults = {
+  message: "Your connection is Great!",
+  isfinished: true,
+  isfailed: false,
+  errorMessage: "",
+  progressValue: 100
+};
+
+const useSpeedTest = jest.fn().mockImplementation(() => {
+  return {
+    startSpeedTest: jest.fn(),
+    stopSpeedTest: jest.fn(),
+    speedTestResults: mockSpeedTestResults,
+    speedTestInProgress: false,
+    speedTestProgress: 100,
+    speedTestStreamId: mockSpeedTestStreamId,
+    setAndFillPlayStatsList: jest.fn(),
+    setAndFillPublishStatsList: jest.fn(),
+    speedTestCounter: mockSpeedTestCounter,
+    statsList: mockStatsList,
+    calculateThePlaySpeedTestResult: jest.fn(),
+    processUpdatedStatsForPlaySpeedTest: jest.fn()
+  };
+});
+
+export default useSpeedTest; 
\ No newline at end of file
diff --git a/react/src/__tests__/hooks/useSpeedTest.test.js b/react/src/__tests__/hooks/useSpeedTest.test.js
new file mode 100644
index 00000000..f9327d0d
--- /dev/null
+++ b/react/src/__tests__/hooks/useSpeedTest.test.js
@@ -0,0 +1,475 @@
+import React from 'react';
+import { renderHook, act, waitFor } from '@testing-library/react';
+import useSpeedTest from '../../hooks/useSpeedTest';
+
+// Mock WebRTC Adaptor
+jest.mock('@antmedia/webrtc_adaptor', () => {
+  return {
+    WebRTCAdaptor: jest.fn().mockImplementation(() => ({
+      publish: jest.fn(),
+      play: jest.fn(),
+      enableStats: jest.fn(),
+      stop: jest.fn(),
+      closeStream: jest.fn(),
+      closeWebSocket: jest.fn(),
+      mediaManager: {
+        bandwidth: 1000,
+        trackDeviceChange: jest.fn()
+      }
+    }))
+  };
+});
+
+// Mock the publishStats reference used in the hook
+beforeEach(() => {
+  // Mock the publishStats reference that's used in calculateThePlaySpeedTestResult
+  if (!global.publishStats) {
+    global.publishStats = { current: null };
+  }
+});
+
+describe('useSpeedTest Hook', () => {
+  const defaultProps = {
+    websocketURL: 'wss://test.antmedia.io:5443/WebRTCAppEE/websocket',
+    peerconnection_config: { iceServers: [] },
+    token: 'test-token',
+    subscriberId: 'test-subscriber-id',
+    subscriberCode: 'test-subscriber-code',
+    isPlayOnly: false
+  };
+
+  beforeEach(() => {
+    jest.clearAllMocks();
+  });
+
+  it('initializes with default values', () => {
+    const { result } = renderHook(() => useSpeedTest(defaultProps));
+    
+    expect(result.current.speedTestObject.message).toBe('Please wait while we are testing your connection speed');
+    expect(result.current.speedTestObject.isfinished).toBe(false);
+    expect(result.current.speedTestObject.isfailed).toBe(false);
+    expect(result.current.speedTestObject.progressValue).toBe(10);
+    expect(result.current.speedTestInProgress).toBe(false);
+    expect(result.current.speedTestProgress.current).toBe(0);
+    expect(result.current.speedTestStreamId).toBeDefined();
+  });
+
+  it('starts and stops speed test', () => {
+    const { result } = renderHook(() => useSpeedTest(defaultProps));
+    
+    act(() => {
+      result.current.startSpeedTest();
+    });
+    
+    expect(result.current.speedTestInProgress).toBe(true);
+    
+    act(() => {
+      result.current.stopSpeedTest();
+    });
+    
+    expect(result.current.speedTestInProgress).toBe(false);
+  });
+
+  it('sets and fills play stats list correctly', () => {
+    const { result } = renderHook(() => useSpeedTest(defaultProps));
+    
+    const mockStats = {
+      currentRoundTripTime: 100,
+      packetsReceived: 200,
+      totalBytesReceivedCount: 300,
+      framesReceived: 400,
+      framesDropped: 500,
+      startTime: 600,
+      currentTimestamp: 700,
+      firstBytesReceivedCount: 800,
+      lastBytesReceived: 900,
+      videoPacketsLost: 1000,
+      audioPacketsLost: 1100,
+      inboundRtpList: [],
+      videoJitterAverageDelay: 50,
+      audioJitterAverageDelay: 60,
+      videoRoundTripTime: 70,
+      audioRoundTripTime: 80
+    };
+    
+    act(() => {
+      result.current.setAndFillPlayStatsList(mockStats);
+    });
+    
+    expect(result.current.statsList.current.length).toBe(1);
+    expect(result.current.statsList.current[0].currentRoundTripTime).toBe(100);
+    expect(result.current.statsList.current[0].packetsReceived).toBe(200);
+    expect(result.current.statsList.current[0].totalBytesReceivedCount).toBe(300);
+    expect(result.current.statsList.current[0].framesReceived).toBe(400);
+    expect(result.current.statsList.current[0].framesDropped).toBe(500);
+    expect(result.current.statsList.current[0].startTime).toBe(600);
+    expect(result.current.statsList.current[0].currentTimestamp).toBe(700);
+    expect(result.current.statsList.current[0].firstBytesReceivedCount).toBe(800);
+    expect(result.current.statsList.current[0].lastBytesReceived).toBe(900);
+    expect(result.current.statsList.current[0].videoPacketsLost).toBe(1000);
+    expect(result.current.statsList.current[0].audioPacketsLost).toBe(1100);
+    expect(result.current.statsList.current[0].videoJitterAverageDelay).toBe(50);
+    expect(result.current.statsList.current[0].audioJitterAverageDelay).toBe(60);
+    expect(result.current.statsList.current[0].videoRoundTripTime).toBe(70);
+    expect(result.current.statsList.current[0].audioRoundTripTime).toBe(80);
+  });
+
+  it('sets and fills publish stats list correctly', () => {
+    const { result } = renderHook(() => useSpeedTest(defaultProps));
+    
+    const mockStats = {
+      videoRoundTripTime: 100,
+      audioRoundTripTime: 200,
+      videoPacketsLost: 300,
+      totalVideoPacketsSent: 400,
+      totalAudioPacketsSent: 500,
+      audioPacketsLost: 600,
+      videoJitter: 700,
+      audioJitter: 800,
+      currentOutgoingBitrate: 900
+    };
+    
+    act(() => {
+      result.current.setAndFillPublishStatsList(mockStats);
+    });
+    
+    expect(result.current.statsList.current.length).toBe(1);
+    expect(result.current.statsList.current[0].videoRoundTripTime).toBe(100);
+    expect(result.current.statsList.current[0].audioRoundTripTime).toBe(200);
+    expect(result.current.statsList.current[0].videoPacketsLost).toBe(300);
+    expect(result.current.statsList.current[0].totalVideoPacketsSent).toBe(400);
+    expect(result.current.statsList.current[0].totalAudioPacketsSent).toBe(500);
+    expect(result.current.statsList.current[0].audioPacketsLost).toBe(600);
+    expect(result.current.statsList.current[0].videoJitter).toBe(700);
+    expect(result.current.statsList.current[0].audioJitter).toBe(800);
+    expect(result.current.statsList.current[0].currentOutgoingBitrate).toBe(900);
+  });
+
+  it('calculates play speed test result with great connection', async () => {
+    
+    const { result } = renderHook(() => {
+      const hook = useSpeedTest(defaultProps);
+      return hook;
+    });
+    
+    act(() => {
+      result.current.startSpeedTest();
+    });
+
+    result.current.statsList.current = [
+      {
+        totalBytesReceivedCount: 1000,
+        framesReceived: 100,
+        framesDropped: 0,
+        currentTimestamp: 2000,
+        startTime: 1000,
+        lastBytesReceived: 1000,
+        firstBytesReceivedCount: 0,
+        videoPacketsLost: 0,
+        audioPacketsLost: 0,
+        inboundRtpList: [{
+          trackIdentifier: 'ARDAMSv',
+          packetsReceived: 100,
+          jitterBufferDelay: 10
+        }, {trackIdentifier: 'ARDAMSa', packetsReceived: 100, jitterBufferDelay: 10}],
+        videoRoundTripTime: '0.05',
+        audioRoundTripTime: '0.05'
+      },
+      {
+        totalBytesReceivedCount: 500,
+        framesReceived: 50,
+        framesDropped: 0,
+        currentTimestamp: 1500,
+        startTime: 1000,
+        lastBytesReceived: 500,
+        firstBytesReceivedCount: 0,
+        videoPacketsLost: 0,
+        audioPacketsLost: 0,
+        inboundRtpList: [{
+          trackIdentifier: 'ARDAMSv',
+          packetsReceived: 50,
+          jitterBufferDelay: 10
+        }, {trackIdentifier: 'ARDAMSa', packetsReceived: 50, jitterBufferDelay: 10}],
+        videoRoundTripTime: '0.05',
+        audioRoundTripTime: '0.05'
+      }
+    ];
+
+    await act(async () => {
+      result.current.calculateThePlaySpeedTestResult();
+    });
+
+    console.log(result.current.speedTestObject);
+    await waitFor(() => {
+      expect(result.current.speedTestObject.message).toBe('Your connection is Great!');
+      expect(result.current.speedTestObject.isfailed).toBe(false);
+      expect(result.current.speedTestObject.progressValue).toBe(100);
+      expect(result.current.speedTestObject.isfinished).toBe(true);
+    });
+  });
+
+  it('calculates play speed test result with moderate connection', async () => {
+    
+    const { result } = renderHook(() => {
+      const hook = useSpeedTest(defaultProps);
+      return hook;
+    });
+    
+    act(() => {
+      result.current.startSpeedTest();
+    });
+
+    result.current.statsList.current = [
+      {
+        totalBytesReceivedCount: 1000,
+        framesReceived: 100,
+        framesDropped: 5,
+        currentTimestamp: 2000,
+        startTime: 1000,
+        lastBytesReceived: 1000,
+        firstBytesReceivedCount: 0,
+        videoPacketsLost: 1,
+        audioPacketsLost: 1,
+        inboundRtpList: [{
+          trackIdentifier: 'ARDAMSv',
+          packetsReceived: 100,
+          jitterBufferDelay: 60
+        }, {trackIdentifier: 'ARDAMSa', packetsReceived: 100, jitterBufferDelay: 60}],
+        videoRoundTripTime: '0.12',
+        audioRoundTripTime: '0.12'
+      },
+      {
+        totalBytesReceivedCount: 500,
+        framesReceived: 50,
+        framesDropped: 2,
+        currentTimestamp: 1500,
+        startTime: 1000,
+        lastBytesReceived: 500,
+        firstBytesReceivedCount: 0,
+        videoPacketsLost: 0,
+        audioPacketsLost: 0,
+        inboundRtpList: [{
+          trackIdentifier: 'ARDAMSv',
+          packetsReceived: 50,
+          jitterBufferDelay: 60
+        }, {trackIdentifier: 'ARDAMSa', packetsReceived: 50, jitterBufferDelay: 60}],
+        videoRoundTripTime: '0.12',
+        audioRoundTripTime: '0.12'
+      }
+    ];
+
+    await act(async () => {
+      result.current.calculateThePlaySpeedTestResult();
+    });
+
+    await waitFor(() => {
+      expect(result.current.speedTestObject.message).toBe('Your connection is moderate, occasional disruptions may occur');
+      expect(result.current.speedTestObject.isfailed).toBe(false);
+      expect(result.current.speedTestObject.progressValue).toBe(100);
+      expect(result.current.speedTestObject.isfinished).toBe(true);
+    }); 
+  });
+
+  it('calculates play speed test result with poor connection', async () => {
+    
+    const { result } = renderHook(() => {
+      const hook = useSpeedTest(defaultProps);
+      return hook;
+    });
+    
+    act(() => {
+      result.current.startSpeedTest();
+    }); 
+
+    result.current.statsList.current = [
+      {
+        totalBytesReceivedCount: 1000,
+        framesReceived: 100,
+        framesDropped: 10,
+        currentTimestamp: 2000,
+        startTime: 1000,
+        lastBytesReceived: 1000,
+        firstBytesReceivedCount: 0,
+        videoPacketsLost: 5,
+        audioPacketsLost: 5,
+        inboundRtpList: [{
+          trackIdentifier: 'ARDAMSv',
+          packetsReceived: 100,
+          jitterBufferDelay: 120
+        }, {trackIdentifier: 'ARDAMSa', packetsReceived: 100, jitterBufferDelay: 120}],
+        videoRoundTripTime: '0.2',
+        audioRoundTripTime: '0.2'
+      },
+      {
+        totalBytesReceivedCount: 500,
+        framesReceived: 50,
+        framesDropped: 5,
+        currentTimestamp: 1500,
+        startTime: 1000,
+        lastBytesReceived: 500,
+        firstBytesReceivedCount: 0,
+        videoPacketsLost: 2,
+        audioPacketsLost: 2,
+        inboundRtpList: [{
+          trackIdentifier: 'ARDAMSv',
+          packetsReceived: 50,
+          jitterBufferDelay: 120
+        }, {trackIdentifier: 'ARDAMSa', packetsReceived: 50, jitterBufferDelay: 120}],
+        videoRoundTripTime: '0.2',
+        audioRoundTripTime: '0.2'
+      }
+    ];
+
+    await act(async () => {
+      result.current.calculateThePlaySpeedTestResult();
+    });
+
+    await waitFor(() => {
+      expect(result.current.speedTestObject.message).toBe('Your connection quality is poor. You may experience interruptions');
+      expect(result.current.speedTestObject.isfailed).toBe(false);
+      expect(result.current.speedTestObject.progressValue).toBe(100);
+      expect(result.current.speedTestObject.isfinished).toBe(true);
+    });
+  });
+
+  it('increments speedTestCounter when processUpdatedStatsForPlaySpeedTest is called', () => {
+    const { result } = renderHook(() => useSpeedTest(defaultProps));
+
+    act(() => {
+      result.current.startSpeedTest();
+    });
+
+    result.current.speedTestCounter.current = 1;
+    result.current.statsList.current = [{}, {}];
+
+    act(() => {
+      result.current.processUpdatedStatsForPlaySpeedTest({});
+    });
+
+    expect(result.current.speedTestCounter.current).toBe(2);
+  });
+
+  it('sets speed test object to failed state', async () => {
+    const { result } = renderHook(() => useSpeedTest(defaultProps));
+    
+    act(() => {
+      result.current.startSpeedTest();
+    });
+    
+    expect(result.current.speedTestInProgress).toBe(true);
+
+    result.current.speedTestObject = {
+      message: "Speed Test",
+      isfinished: false,
+      isfailed: false,
+      errorMessage: "",
+      progressValue: 50
+    };
+
+    result.current.setSpeedTestObject = jest.fn();
+
+    await act(async () => {
+      result.current.setSpeedTestObjectFailed('Error message');
+    });
+
+    await waitFor(() => {
+      expect(result.current.speedTestObject.message).toBe('Error message');
+      expect(result.current.speedTestObject.isfinished).toBe(false);
+      expect(result.current.speedTestObject.isfailed).toBe(true);
+      expect(result.current.speedTestObject.errorMessage).toBe('Error message');
+      expect(result.current.speedTestObject.progressValue).toBe(0);
+    });
+  });
+
+  it('sets speed test object progress correctly', async () => {
+    const { result } = renderHook(() => useSpeedTest(defaultProps));
+    
+    act(() => {
+      result.current.startSpeedTest();
+    });
+    
+    expect(result.current.speedTestInProgress).toBe(true);
+
+    await act(async () => {
+      result.current.setSpeedTestObjectProgress(50);
+    });
+
+    await waitFor(() => {
+      expect(result.current.speedTestObject.isfinished).toBe(false);
+      expect(result.current.speedTestObject.isfailed).toBe(false);
+      expect(result.current.speedTestObject.errorMessage).toBe('');
+      expect(result.current.speedTestObject.progressValue).toBe(50);
+    });
+  });
+
+  it('handles progress value greater than 100', async () => {
+    const { result } = renderHook(() => useSpeedTest(defaultProps));
+    
+    act(() => {
+      result.current.startSpeedTest();
+    });
+    
+    expect(result.current.speedTestInProgress).toBe(true);
+    await act(async () => {
+      result.current.setSpeedTestObjectProgress(150);
+    });
+
+    const stopSpeedTest = jest.fn();
+    //expect(stopSpeedTest).toHaveBeenCalled();
+    expect(result.current.speedTestObject.message).toBe('Speed test failed. It may be due to firewall, wi-fi or network restrictions. Change your network or Try again ');
+    expect(result.current.speedTestObject.isfinished).toBe(false);
+    expect(result.current.speedTestObject.isfailed).toBe(true);
+    expect(result.current.speedTestObject.errorMessage).toBe('Speed test failed. It may be due to firewall, wi-fi or network restrictions. Change your network or Try again ');
+    expect(result.current.speedTestObject.progressValue).toBe(0);
+  });
+
+  it('updates progress and stats list on subsequent iterations', async () => {
+    const { result } = renderHook(() => useSpeedTest(defaultProps));
+    
+    act(() => {
+      result.current.startSpeedTest();
+    });
+    
+    expect(result.current.speedTestInProgress).toBe(true);
+    result.current.speedTestCounter.current = 1;
+    result.current.statsList.current = [{}, {}];
+    result.current.setAndFillPlayStatsList = jest.fn();
+    result.current.setSpeedTestObjectProgress = jest.fn();
+    result.current.setSpeedTestObject = jest.fn();
+
+    result.current.processUpdatedStatsForPlaySpeedTest({});
+
+    expect(result.current.statsList.current).toEqual([{}, {}, {}]);
+  });
+  it('updates speed test object progress when iterations are insufficient', async () => {
+    const { result } = renderHook(() => useSpeedTest(defaultProps));
+    
+    act(() => {
+      result.current.startSpeedTest();
+    });
+    
+    expect(result.current.speedTestInProgress).toBe(true);
+
+    result.current.speedTestCounter.current = 2;
+    result.current.statsList.current = [{}, {}];
+    result.current.setSpeedTestObjectProgress = jest.fn();
+    result.current.setSpeedTestObject = jest.fn();
+    result.current.speedTestObject = {
+      message: "Speed Test",
+      isfinished: false,
+      isfailed: false,
+      errorMessage: "",
+      progressValue: 0
+    };
+
+    result.current.processUpdatedStatsForPlaySpeedTest({});
+
+    expect(result.current.setSpeedTestObject).not.toHaveBeenCalledWith({
+      message: result.current.speedTestObject.message,
+      isfinished: false,
+      isfailed: false,
+      errorMessage: "",
+      progressValue: 60
+    });
+  });
+}); 
\ No newline at end of file
diff --git a/react/src/__tests__/pages/AntMedia.test.js b/react/src/__tests__/pages/AntMedia.test.js
index 6d7da8be..f1dbb942 100644
--- a/react/src/__tests__/pages/AntMedia.test.js
+++ b/react/src/__tests__/pages/AntMedia.test.js
@@ -3317,466 +3317,7 @@ describe('AntMedia Component', () => {
       expect(currentConference.checkVideoTrackHealth()).toBe(false);
     });
   });
-
-  it('sets and fills play stats list correctly', async () => {
-    let currentConference;
-    const TestMockChild = createMockChild(conf => {
-      currentConference = conf;
-    });
-
-    const mockStats = {
-      currentRoundTripTime: 100,
-      packetsReceived: 200,
-      totalBytesReceivedCount: 300,
-      framesReceived: 400,
-      framesDropped: 500,
-      startTime: 600,
-      currentTimestamp: 700,
-      firstBytesReceivedCount: 800,
-      lastBytesReceived: 900,
-      videoPacketsLost: 1000,
-    };
-
-    const {container} = render(
-        <ThemeProvider theme={theme(ThemeList.Green)}>
-          <AntMedia isTest={true}>
-            <TestMockChild/>
-          </AntMedia>
-        </ThemeProvider>);
-
-    await waitFor(() => {
-      expect(webRTCAdaptorConstructor).not.toBe(undefined);
-    });
-
-    await act(async () => {
-      currentConference.setAndFillPlayStatsList(mockStats);
-    });
-
-    expect(currentConference.statsList.current.currentRoundTripTime).not.toBe(100);
-    expect(currentConference.statsList.current.packetsReceived).not.toBe(200);
-    expect(currentConference.statsList.current.totalBytesReceivedCount).not.toBe(300);
-    expect(currentConference.statsList.current.framesReceived).not.toBe(400);
-    expect(currentConference.statsList.current.framesDropped).not.toBe(500);
-    expect(currentConference.statsList.current.startTime).not.toBe(600);
-    expect(currentConference.statsList.current.currentTimestamp).not.toBe(700);
-    expect(currentConference.statsList.current.firstBytesReceivedCount).not.toBe(800);
-    expect(currentConference.statsList.current.lastBytesReceived).not.toBe(900);
-    expect(currentConference.statsList.current.videoPacketsLost).not.toBe(1000);
-  });
-
-  it('sets and fills publish stats list correctly', async () => {
-    let currentConference;
-    const TestMockChild = createMockChild(conf => {
-      currentConference = conf;
-    });
-
-    const mockStats = {
-      videoRoundTripTime: 100,
-      audioRoundTripTime: 200,
-      videoPacketsLost: 300,
-      totalVideoPacketsSent: 400,
-      totalAudioPacketsSent: 500,
-      audioPacketsLost: 600,
-      videoJitter: 700,
-      audioJitter: 800,
-      currentOutgoingBitrate: 900,
-    };
-
-    const {container} = render(
-        <ThemeProvider theme={theme(ThemeList.Green)}>
-          <AntMedia isTest={true}>
-            <TestMockChild/>
-          </AntMedia>
-        </ThemeProvider>);
-
-    await waitFor(() => {
-      expect(webRTCAdaptorConstructor).not.toBe(undefined);
-    });
-
-    await act(async () => {
-      currentConference.setAndFillPublishStatsList(mockStats);
-    });
-
-    await waitFor(() => {
-      expect(currentConference.statsList.current.videoRoundTripTime).not.toBe(100);
-      expect(currentConference.statsList.current.audioRoundTripTime).not.toBe(200);
-      expect(currentConference.statsList.current.videoPacketsLost).not.toBe(300);
-      expect(currentConference.statsList.current.totalVideoPacketsSent).not.toBe(400);
-      expect(currentConference.statsList.current.totalAudioPacketsSent).not.toBe(500);
-      expect(currentConference.statsList.current.audioPacketsLost).not.toBe(600);
-      expect(currentConference.statsList.current.videoJitter).not.toBe(700);
-      expect(currentConference.statsList.current.audioJitter).not.toBe(800);
-      expect(currentConference.statsList.current.currentOutgoingBitrate).not.toBe(900);
-    });
-  });
-
-  it('sets speed test object to failed state', async () => {
-    // Create a local reference for this test
-    let currentConference;
-    const TestMockChild = createMockChild(conf => {
-      currentConference = conf;
-    });
-    
-    const {container} = render(
-        <ThemeProvider theme={theme(ThemeList.Green)}>
-          <AntMedia isTest={true}>
-            <TestMockChild/>
-          </AntMedia>
-        </ThemeProvider>);
-
-    await waitFor(() => {
-      expect(webRTCAdaptorConstructor).not.toBe(undefined);
-    });
-
-    currentConference.speedTestObject = {
-      message: "Speed Test",
-      isfinished: false,
-      isfailed: false,
-      errorMessage: "",
-      progressValue: 50
-    };
-
-    currentConference.setSpeedTestObject = jest.fn();
-
-    await act(async () => {
-      currentConference.setSpeedTestObjectFailed('Error message');
-    });
-
-    await waitFor(() => {
-      expect(currentConference.speedTestObject.message).toBe('Error message');
-      expect(currentConference.speedTestObject.isfinished).toBe(false);
-      expect(currentConference.speedTestObject.isfailed).toBe(true);
-      expect(currentConference.speedTestObject.errorMessage).toBe('Error message');
-      expect(currentConference.speedTestObject.progressValue).toBe(0);
-    });
-  });
-
-  it('sets speed test object progress correctly', async () => {
-    let currentConference;
-    const TestMockChild = createMockChild(conf => {
-      currentConference = conf;
-    });
-
-    const {container} = render(
-        <ThemeProvider theme={theme(ThemeList.Green)}>
-          <AntMedia isTest={true}>
-            <TestMockChild/>
-          </AntMedia>
-        </ThemeProvider>);
-
-    await waitFor(() => {
-      expect(webRTCAdaptorConstructor).not.toBe(undefined);
-    });
-
-    await act(async () => {
-      currentConference.setSpeedTestObjectProgress(50);
-    });
-
-    await waitFor(() => {
-      expect(currentConference.speedTestObject.isfinished).toBe(false);
-      expect(currentConference.speedTestObject.isfailed).toBe(false);
-      expect(currentConference.speedTestObject.errorMessage).toBe('');
-      expect(currentConference.speedTestObject.progressValue).toBe(50);
-    });
-  });
-
-  it('handles progress value greater than 100', async () => {
-    let currentConference;
-    const TestMockChild = createMockChild(conf => {
-      currentConference = conf;
-    });
-
-    const {container} = render(
-        <ThemeProvider theme={theme(ThemeList.Green)}>
-          <AntMedia isTest={true}>
-            <TestMockChild/>
-          </AntMedia>
-        </ThemeProvider>);
-
-    await waitFor(() => {
-      expect(webRTCAdaptorConstructor).not.toBe(undefined);
-    });
-
-    await act(async () => {
-      currentConference.setSpeedTestObjectProgress(150);
-    });
-
-    const stopSpeedTest = jest.fn();
-    //expect(stopSpeedTest).toHaveBeenCalled();
-    expect(currentConference.speedTestObject.message).toBe('Speed test failed. It may be due to firewall, wi-fi or network restrictions. Change your network or Try again ');
-    expect(currentConference.speedTestObject.isfinished).toBe(false);
-    expect(currentConference.speedTestObject.isfailed).toBe(true);
-    expect(currentConference.speedTestObject.errorMessage).toBe('Speed test failed. It may be due to firewall, wi-fi or network restrictions. Change your network or Try again ');
-    expect(currentConference.speedTestObject.progressValue).toBe(0);
-  });
-
-  it('calculates play speed test result with great connection', async () => {
-    let currentConference;
-    const TestMockChild = createMockChild(conf => {
-      currentConference = conf;
-    });
-
-    const {container} = render(
-        <ThemeProvider theme={theme(ThemeList.Green)}>
-          <AntMedia isTest={true}>
-            <TestMockChild/>
-          </AntMedia>
-        </ThemeProvider>);
-
-    await waitFor(() => {
-      expect(webRTCAdaptorConstructor).not.toBe(undefined);
-    });
-
-    currentConference.statsList.current = [
-      {
-        totalBytesReceivedCount: 1000,
-        framesReceived: 100,
-        framesDropped: 0,
-        currentTimestamp: 2000,
-        startTime: 1000,
-        lastBytesReceived: 1000,
-        firstBytesReceivedCount: 0,
-        videoPacketsLost: 0,
-        audioPacketsLost: 0,
-        inboundRtpList: [{
-          trackIdentifier: 'ARDAMSv',
-          packetsReceived: 100,
-          jitterBufferDelay: 10
-        }, {trackIdentifier: 'ARDAMSa', packetsReceived: 100, jitterBufferDelay: 10}],
-        videoRoundTripTime: '0.05',
-        audioRoundTripTime: '0.05'
-      },
-      {
-        totalBytesReceivedCount: 500,
-        framesReceived: 50,
-        framesDropped: 0,
-        currentTimestamp: 1500,
-        startTime: 1000,
-        lastBytesReceived: 500,
-        firstBytesReceivedCount: 0,
-        videoPacketsLost: 0,
-        audioPacketsLost: 0,
-        inboundRtpList: [{
-          trackIdentifier: 'ARDAMSv',
-          packetsReceived: 50,
-          jitterBufferDelay: 10
-        }, {trackIdentifier: 'ARDAMSa', packetsReceived: 50, jitterBufferDelay: 10}],
-        videoRoundTripTime: '0.05',
-        audioRoundTripTime: '0.05'
-      }
-    ];
-
-    await act(async () => {
-      currentConference.calculateThePlaySpeedTestResult();
-    });
-
-    expect(currentConference.speedTestObject.message).toBe('Your connection is Great!');
-    expect(currentConference.speedTestObject.isfailed).toBe(false);
-    expect(currentConference.speedTestObject.progressValue).toBe(100);
-    expect(currentConference.speedTestObject.isfinished).toBe(true);
-  });
-
-  it('calculates play speed test result with moderate connection', async () => {
-    let currentConference;
-    const TestMockChild = createMockChild(conf => {
-      currentConference = conf;
-    });
-
-    const {container} = render(
-        <ThemeProvider theme={theme(ThemeList.Green)}>
-          <AntMedia isTest={true}>
-            <TestMockChild/>
-          </AntMedia>
-        </ThemeProvider>);
-
-    await waitFor(() => {
-      expect(webRTCAdaptorConstructor).not.toBe(undefined);
-    });
-
-    currentConference.statsList.current = [
-      {
-        totalBytesReceivedCount: 1000,
-        framesReceived: 100,
-        framesDropped: 5,
-        currentTimestamp: 2000,
-        startTime: 1000,
-        lastBytesReceived: 1000,
-        firstBytesReceivedCount: 0,
-        videoPacketsLost: 1,
-        audioPacketsLost: 1,
-        inboundRtpList: [{
-          trackIdentifier: 'ARDAMSv',
-          packetsReceived: 100,
-          jitterBufferDelay: 60
-        }, {trackIdentifier: 'ARDAMSa', packetsReceived: 100, jitterBufferDelay: 60}],
-        videoRoundTripTime: '0.12',
-        audioRoundTripTime: '0.12'
-      },
-      {
-        totalBytesReceivedCount: 500,
-        framesReceived: 50,
-        framesDropped: 2,
-        currentTimestamp: 1500,
-        startTime: 1000,
-        lastBytesReceived: 500,
-        firstBytesReceivedCount: 0,
-        videoPacketsLost: 0,
-        audioPacketsLost: 0,
-        inboundRtpList: [{
-          trackIdentifier: 'ARDAMSv',
-          packetsReceived: 50,
-          jitterBufferDelay: 60
-        }, {trackIdentifier: 'ARDAMSa', packetsReceived: 50, jitterBufferDelay: 60}],
-        videoRoundTripTime: '0.12',
-        audioRoundTripTime: '0.12'
-      }
-    ];
-
-    await act(async () => {
-      currentConference.calculateThePlaySpeedTestResult();
-    });
-
-    expect(currentConference.speedTestObject.message).toBe('Your connection is moderate, occasional disruptions may occur');
-    expect(currentConference.speedTestObject.isfailed).toBe(false);
-    expect(currentConference.speedTestObject.progressValue).toBe(100);
-    expect(currentConference.speedTestObject.isfinished).toBe(true);
-  });
-
-  it('calculates play speed test result with poor connection', async () => {
-    let currentConference;
-    const TestMockChild = createMockChild(conf => {
-      currentConference = conf;
-    });
-
-    const {container} = render(
-        <ThemeProvider theme={theme(ThemeList.Green)}>
-          <AntMedia isTest={true}>
-            <TestMockChild/>
-          </AntMedia>
-        </ThemeProvider>);
-
-    await waitFor(() => {
-      expect(webRTCAdaptorConstructor).not.toBe(undefined);
-    });
-
-    currentConference.statsList.current = [
-      {
-        totalBytesReceivedCount: 1000,
-        framesReceived: 100,
-        framesDropped: 10,
-        currentTimestamp: 2000,
-        startTime: 1000,
-        lastBytesReceived: 1000,
-        firstBytesReceivedCount: 0,
-        videoPacketsLost: 5,
-        audioPacketsLost: 5,
-        inboundRtpList: [{
-          trackIdentifier: 'ARDAMSv',
-          packetsReceived: 100,
-          jitterBufferDelay: 120
-        }, {trackIdentifier: 'ARDAMSa', packetsReceived: 100, jitterBufferDelay: 120}],
-        videoRoundTripTime: '0.2',
-        audioRoundTripTime: '0.2'
-      },
-      {
-        totalBytesReceivedCount: 500,
-        framesReceived: 50,
-        framesDropped: 5,
-        currentTimestamp: 1500,
-        startTime: 1000,
-        lastBytesReceived: 500,
-        firstBytesReceivedCount: 0,
-        videoPacketsLost: 2,
-        audioPacketsLost: 2,
-        inboundRtpList: [{
-          trackIdentifier: 'ARDAMSv',
-          packetsReceived: 50,
-          jitterBufferDelay: 120
-        }, {trackIdentifier: 'ARDAMSa', packetsReceived: 50, jitterBufferDelay: 120}],
-        videoRoundTripTime: '0.2',
-        audioRoundTripTime: '0.2'
-      }
-    ];
-
-    await act(async () => {
-      currentConference.calculateThePlaySpeedTestResult();
-    });
-
-    expect(currentConference.speedTestObject.message).toBe('Your connection quality is poor. You may experience interruptions');
-    expect(currentConference.speedTestObject.isfailed).toBe(false);
-    expect(currentConference.speedTestObject.progressValue).toBe(100);
-    expect(currentConference.speedTestObject.isfinished).toBe(true);
-  });
-
-  it('updates progress and stats list on subsequent iterations', async () => {
-    let currentConference;
-    const TestMockChild = createMockChild(conf => {
-      currentConference = conf;
-    });
-
-    const {container} = render(
-        <ThemeProvider theme={theme(ThemeList.Green)}>
-          <AntMedia isTest={true}>
-            <TestMockChild/>
-          </AntMedia>
-        </ThemeProvider>);
-
-    await waitFor(() => {
-      expect(webRTCAdaptorConstructor).not.toBe(undefined);
-    });
-
-    currentConference.speedTestCounter.current = 1;
-    currentConference.statsList.current = [{}, {}];
-    currentConference.setAndFillPlayStatsList = jest.fn();
-    currentConference.setSpeedTestObjectProgress = jest.fn();
-    currentConference.setSpeedTestObject = jest.fn();
-
-    currentConference.processUpdatedStatsForPlaySpeedTest({});
-
-    expect(currentConference.statsList.current).toEqual([{}, {}, {}]);
-  });
-
-  it('updates speed test object progress when iterations are insufficient', async () => {
-    // Create a local reference for this test
-    let currentConference;
-    const TestMockChild = createMockChild(conf => {
-      currentConference = conf;
-    });
-    
-    const {container} = render(
-        <ThemeProvider theme={theme(ThemeList.Green)}>
-          <AntMedia isTest={true}>
-            <TestMockChild/>
-          </AntMedia>
-        </ThemeProvider>);
-
-    await waitFor(() => {
-      expect(webRTCAdaptorConstructor).not.toBe(undefined);
-    });
-
-    currentConference.speedTestCounter = { current: 2 };
-    currentConference.statsList = { current: [{}, {}] };
-    currentConference.setSpeedTestObjectProgress = jest.fn();
-    currentConference.setSpeedTestObject = jest.fn();
-    currentConference.speedTestObject = {
-      message: "Speed Test",
-      isfinished: false,
-      isfailed: false,
-      errorMessage: "",
-      progressValue: 0
-    };
-
-    currentConference.processUpdatedStatsForPlaySpeedTest({});
-
-    expect(currentConference.setSpeedTestObject).not.toHaveBeenCalledWith({
-      message: currentConference.speedTestObject.message,
-      isfinished: false,
-      isfailed: false,
-      errorMessage: "",
-      progressValue: 60
-    });
-  });
-
+  
   describe('loadMoreParticipants', () => {
     it('get subtracks as many as loadingStepSize', async () => {
       // Create a local reference for this test
diff --git a/react/src/hooks/useSpeedTest.js b/react/src/hooks/useSpeedTest.js
new file mode 100644
index 00000000..cbe3d66e
--- /dev/null
+++ b/react/src/hooks/useSpeedTest.js
@@ -0,0 +1,476 @@
+import { useState, useRef, useCallback, useEffect } from 'react';
+import { WebRTCAdaptor } from '@antmedia/webrtc_adaptor';
+
+export default function useSpeedTest(props) {
+  const {
+    websocketURL,
+    peerconnection_config,
+    token,
+    subscriberId,
+    subscriberCode,
+    isPlayOnly
+  } = props;
+
+  const [speedTestInProgress, setSpeedTestInProgress] = useState(false);
+
+  const speedTestProgress = useRef(0);
+  const speedTestForPublishWebRtcAdaptor = useRef(null);
+  const speedTestForPlayWebRtcAdaptor = useRef(null);
+  const speedTestStreamId = useRef(Date.now());
+  const speedTestCounter = useRef(0);
+  const speedTestPlayStarted = useRef(false);
+  const statsList = useRef([]);
+  const playStatsList = useRef([]);
+  const [speedTestObject, setSpeedTestObject] = useState({
+    message: "Please wait while we are testing your connection speed",
+    isfinished: false,
+    isfailed: false,
+    errorMessage: "",
+    progressValue: 10
+});
+
+  const startSpeedTest = useCallback(() => {
+    console.log("Starting speed test");
+    if (!speedTestInProgress) {
+      setSpeedTestInProgress(true);
+      speedTestStreamId.current = Date.now();
+      
+      if (isPlayOnly === "true" || isPlayOnly === true) {
+        createSpeedTestForPlayWebRtcAdaptor();
+      } else {
+        createSpeedTestForPublishWebRtcAdaptor();
+      }
+      
+      // Set a timeout to handle stuck tests
+      setTimeout(() => {
+        if (speedTestProgress < 40) {
+          // It means that it's stuck before publish started
+          stopSpeedTest();
+          setSpeedTestObjectFailed("Speed test failed. It may be due to firewall, wi-fi or network restrictions. Change your network or Try again");
+        }
+      }, 15000);
+    }
+  }, [speedTestInProgress, isPlayOnly]);
+
+  const stopSpeedTest = useCallback(() => {
+    if (speedTestForPublishWebRtcAdaptor.current !== null) {
+      speedTestForPublishWebRtcAdaptor.current.stop("speedTestStream" + speedTestStreamId.current);
+      speedTestForPublishWebRtcAdaptor.current.closeStream();
+      speedTestForPublishWebRtcAdaptor.current.closeWebSocket();
+    }
+
+    if (speedTestForPlayWebRtcAdaptor.current !== null) {
+      speedTestForPlayWebRtcAdaptor.current.stop("speedTestSampleStream");
+      speedTestForPlayWebRtcAdaptor.current.closeWebSocket();
+    }
+
+    speedTestForPublishWebRtcAdaptor.current = null;
+    speedTestForPlayWebRtcAdaptor.current = null;
+
+    setSpeedTestInProgress(false);
+    speedTestProgress.current = 0;
+  }, []);
+
+  const setSpeedTestObjectProgress = useCallback((progressValue) => {
+    // if progress value is more than 100, it means that speed test is failed, and we can not get or set the stat list properly
+    console.log("setSpeedTestObjectProgress is called");
+    console.log("progressValue: ", progressValue);
+
+    //TODO: It's just a insurance to not encounter this case. It's put there for a workaround solution in production for fakeeh. Remove it later - mekya
+    if (progressValue > 100) {
+        // we need to stop the speed test and set the speed test object as failed
+        stopSpeedTest();
+        setSpeedTestObjectFailed("Speed test failed. It may be due to firewall, wi-fi or network restrictions. Change your network or Try again ");
+        return;
+    }
+    let tempSpeedTestObject = {};
+    tempSpeedTestObject.message = speedTestObject.message;
+    tempSpeedTestObject.isfinished = false;
+    tempSpeedTestObject.isfailed = false;
+    tempSpeedTestObject.errorMessage = "";
+    tempSpeedTestObject.progressValue = progressValue;
+    speedTestProgress.current = tempSpeedTestObject.progressValue;
+    setSpeedTestObject(tempSpeedTestObject);
+  }, []);
+
+  const setSpeedTestObjectFailed = useCallback((errorMessage) => {
+    console.error("Speed test failed: ", errorMessage);
+    setSpeedTestInProgress(false);
+    speedTestProgress.current = 0;
+
+    setSpeedTestObject({
+      message: errorMessage,
+      isfinished: false,
+      isfailed: true,
+      errorMessage: errorMessage,
+      progressValue: 0
+    });
+  }, []);
+
+  const createSpeedTestForPublishWebRtcAdaptor = useCallback(() => {
+    speedTestForPublishWebRtcAdaptor.current = new WebRTCAdaptor({
+      websocket_url: websocketURL,
+      mediaConstraints: { video: true, audio: false },
+      sdp_constraints: {
+        OfferToReceiveAudio: false, 
+        OfferToReceiveVideo: false,
+      },
+      peerconnection_config: peerconnection_config,
+      debug: true,
+      callback: speedTestForPublishWebRtcAdaptorInfoCallback,
+      callbackError: speedTestForPublishWebRtcAdaptorErrorCallback,
+      purposeForTest: "publish-speed-test"
+    });
+  }, [websocketURL, peerconnection_config]);
+
+  const speedTestForPublishWebRtcAdaptorInfoCallback = useCallback((info, obj) => {
+    if (info === "initialized") {
+      speedTestCounter.current = 0;
+      setSpeedTestObjectProgress(10);
+      speedTestForPublishWebRtcAdaptor.current.publish(
+        "speedTestStream" + speedTestStreamId.current, 
+        token, 
+        subscriberId, 
+        subscriberCode,
+        "speedTestStream" + speedTestStreamId.current, 
+        "", 
+        ""
+      );
+    }
+    else if (info === "publish_started") {
+      speedTestCounter.current = 0;
+      console.log("speed test publish started");
+      setSpeedTestObjectProgress(20);
+      speedTestForPublishWebRtcAdaptor.current.enableStats("speedTestStream" + speedTestStreamId.current);
+    }
+    else if (info === "updated_stats") {
+      if (speedTestCounter.current === 0) {
+        statsList.current = []; // reset stats list if it is the first time
+      }
+      setSpeedTestObjectProgress(20 + (speedTestCounter.current * 20));
+
+      speedTestCounter.current = speedTestCounter.current + 1;
+      setAndFillPublishStatsList(obj);
+
+      if (speedTestCounter.current > 3 && statsList.current.length > 3) {
+        calculateThePublishSpeedTestResult();
+      } else {
+        setSpeedTestObjectProgress(20 + (speedTestCounter.current * 20));
+        let tempSpeedTestObject = {};
+        tempSpeedTestObject.message = speedTestObject.message;
+        tempSpeedTestObject.isfinished = false;
+        tempSpeedTestObject.isfailed = false;
+        tempSpeedTestObject.errorMessage = "";
+        tempSpeedTestObject.progressValue = 20 + (speedTestCounter.current * 20);
+      }
+    }
+    else if (info === "ice_connection_state_changed") {
+      console.log("speed test ice connection state changed");
+    }
+  }, [token, subscriberId, subscriberCode]);
+
+  const setAndFillPublishStatsList = useCallback((obj) => {
+    let tempStatsList = statsList.current;
+    let tempStats = {};
+    tempStats.videoRoundTripTime = obj.videoRoundTripTime;
+    tempStats.audioRoundTripTime = obj.audioRoundTripTime;
+    tempStats.videoPacketsLost = obj.videoPacketsLost;
+    tempStats.totalVideoPacketsSent = obj.totalVideoPacketsSent;
+    tempStats.totalAudioPacketsSent = obj.totalAudioPacketsSent;
+    tempStats.audioPacketsLost = obj.audioPacketsLost;
+    tempStats.videoJitter = obj.videoJitter;
+    tempStats.audioJitter = obj.audioJitter;
+    tempStats.currentOutgoingBitrate = obj.currentOutgoingBitrate;
+    tempStatsList.push(tempStats);
+    statsList.current = tempStatsList;
+  }, []);
+
+  const calculateThePublishSpeedTestResult = useCallback(() => {
+    if (statsList.current.length === 0) {
+      setSpeedTestObjectFailed("No stats received");
+      return;
+    }
+    
+    let updatedStats = {};
+
+    console.log("Calculating publish speed test result");
+
+    updatedStats.videoRoundTripTime = parseFloat(statsList.current[statsList.current.length - 1].videoRoundTripTime); // we can use the last value
+    updatedStats.videoRoundTripTime = (updatedStats.videoRoundTripTime === -1) ? 0 : updatedStats.videoRoundTripTime;
+
+    updatedStats.audioRoundTripTime = parseFloat(statsList.current[statsList.current.length - 1].audioRoundTripTime); // we can use the last value
+    updatedStats.audioRoundTripTime = (updatedStats.audioRoundTripTime === -1) ? 0 : updatedStats.audioRoundTripTime;
+
+    updatedStats.videoPacketsLost = parseInt(statsList.current[statsList.current.length - 1].videoPacketsLost)
+        + parseInt(statsList.current[statsList.current.length - 2].videoPacketsLost)
+        + parseInt(statsList.current[statsList.current.length - 3].videoPacketsLost);
+
+    updatedStats.videoPacketsLost = (updatedStats.videoPacketsLost < 0) ? 0 : updatedStats.videoPacketsLost;
+
+    updatedStats.totalVideoPacketsSent = parseInt(statsList.current[statsList.current.length - 1].totalVideoPacketsSent)
+        + parseInt(statsList.current[statsList.current.length - 2].totalVideoPacketsSent)
+        + parseInt(statsList.current[statsList.current.length - 3].totalVideoPacketsSent);
+
+    updatedStats.totalVideoPacketsSent = (updatedStats.totalVideoPacketsSent < 0) ? 0 : updatedStats.totalVideoPacketsSent;
+
+    updatedStats.audioPacketsLost = parseInt(statsList.current[statsList.current.length - 1].audioPacketsLost)
+        + parseInt(statsList.current[statsList.current.length - 2].audioPacketsLost)
+        + parseInt(statsList.current[statsList.current.length - 3].audioPacketsLost);
+
+    updatedStats.totalAudioPacketsSent = parseInt(statsList.current[statsList.current.length - 1].totalAudioPacketsSent)
+        + parseInt(statsList.current[statsList.current.length - 2].totalAudioPacketsSent)
+        + parseInt(statsList.current[statsList.current.length - 3].totalAudioPacketsSent);
+
+    updatedStats.totalAudioPacketsSent = (updatedStats.totalAudioPacketsSent < 0) ? 0 : updatedStats.totalAudioPacketsSent;
+
+    updatedStats.audioPacketsLost = (updatedStats.audioPacketsLost < 0) ? 0 : updatedStats.audioPacketsLost;
+
+    updatedStats.videoJitter = (parseFloat(statsList.current[statsList.current.length - 1].videoJitter) + parseFloat(statsList.current[statsList.current.length - 2].videoJitter)) / 2.0;
+    updatedStats.videoJitter = (updatedStats.videoJitter === -1) ? 0 : updatedStats.videoJitter;
+
+    updatedStats.audioJitter = (parseFloat(statsList.current[statsList.current.length - 1].audioJitter) + parseFloat(statsList.current[statsList.current.length - 2].audioJitter)) / 2.0;
+    updatedStats.audioJitter = (updatedStats.audioJitter === -1) ? 0 : updatedStats.audioJitter;
+
+    updatedStats.currentOutgoingBitrate = parseInt(statsList.current[statsList.current.length - 1].currentOutgoingBitrate); // we can use the last value
+    updatedStats.currentOutgoingBitrate = (updatedStats.currentOutgoingBitrate === -1) ? 0 : updatedStats.currentOutgoingBitrate;
+
+    let rtt = ((parseFloat(updatedStats.videoRoundTripTime) + parseFloat(updatedStats.audioRoundTripTime)) / 2).toPrecision(3);
+    let packetLost = parseInt(updatedStats.videoPacketsLost) + parseInt(updatedStats.audioPacketsLost);
+    let packetLostPercentage = ((updatedStats.videoPacketsLost + updatedStats.audioPacketsLost) / (updatedStats.totalVideoPacketsSent + updatedStats.totalAudioPacketsSent)) * 100;
+    let jitter = ((parseFloat(updatedStats.videoJitter) + parseInt(updatedStats.audioJitter)) / 2).toPrecision(3);
+    let outgoingBitrate = parseInt(updatedStats.currentOutgoingBitrate);
+    let bandwidth = speedTestForPublishWebRtcAdaptor.current?.mediaManager?.bandwidth ? parseInt(speedTestForPublishWebRtcAdaptor.current.mediaManager.bandwidth) : 0;
+    
+    console.log("* rtt: " + rtt);
+    console.log("* packetLost: " + packetLost);
+    console.log("* totalPacketSent: " + (updatedStats.totalVideoPacketsSent + updatedStats.totalAudioPacketsSent));
+    console.log("* packetLostPercentage: " + packetLostPercentage);
+    console.log("* jitter: " + jitter);
+    console.log("* outgoingBitrate: " + outgoingBitrate);
+    console.log("* bandwidth: " + bandwidth);
+
+    let speedTestResult = {};
+
+    if (rtt >= 0.2 || packetLostPercentage >= 3.5 || jitter >= 0.2) {
+      console.log("-> Your connection quality is poor. You may experience interruptions");
+      speedTestResult.message = "Your connection quality is poor. You may experience interruptions";
+    } else if (rtt >= 0.1 || packetLostPercentage >= 2 || jitter >= 0.08) {
+      console.log("-> Your connection is moderate, occasional disruptions may occur");
+      speedTestResult.message = "Your connection is moderate, occasional disruptions may occur";
+    } else if (rtt >= 0.03 || jitter >= 0.02 || packetLostPercentage >= 1) {
+      console.log("-> Your connection is good.");
+      speedTestResult.message = "Your connection is Good.";
+    } else {
+      console.log("-> Your connection is great");
+      speedTestResult.message = "Your connection is Great!";
+    }
+
+    speedTestResult.isfailed = false;
+    speedTestResult.errorMessage = "";
+    speedTestResult.progressValue = 100;
+    speedTestResult.isfinished = true;
+    
+    speedTestProgress.current = 100;
+    setSpeedTestObject(speedTestResult);
+    stopSpeedTest();
+  }, []);
+
+  const speedTestForPublishWebRtcAdaptorErrorCallback = useCallback((error, message) => {
+    console.error("Error in speed test publish: ", error, message);
+    setSpeedTestObjectFailed("There is an error('" + error + "'). Please try again later...");
+    stopSpeedTest();
+  }, []);
+
+  const createSpeedTestForPlayWebRtcAdaptor = useCallback(() => {
+    speedTestPlayStarted.current = false;
+    speedTestForPlayWebRtcAdaptor.current = new WebRTCAdaptor({
+      websocket_url: websocketURL,
+      mediaConstraints: { video: false, audio: false },
+      playOnly: true,
+      sdp_constraints: {
+        OfferToReceiveAudio: false, 
+        OfferToReceiveVideo: false,
+      },
+      peerconnection_config: peerconnection_config,
+      debug: true,
+      callback: speedTestForPlayWebRtcAdaptorInfoCallback,
+      callbackError: speedTestForPlayWebRtcAdaptorErrorCallback,
+      purposeForTest: "play-speed-test"
+    });
+  }, [websocketURL, peerconnection_config]);
+
+  const speedTestForPlayWebRtcAdaptorInfoCallback = useCallback((info, obj) => {
+    if (info === "initialized") {
+      speedTestPlayStarted.current = false;
+      speedTestForPlayWebRtcAdaptor.current.play("speedTestSampleStream", "", "", [], "", "", "");
+    } else if (info === "play_started") {
+      console.log("speed test play started");
+      speedTestPlayStarted.current = true;
+      setSpeedTestObjectProgress(20);
+      speedTestForPlayWebRtcAdaptor.current?.enableStats("speedTestSampleStream");
+    }
+    else if (info === "updated_stats") {
+      processUpdatedStatsForPlaySpeedTest(obj);
+    } else if (info === "ice_connection_state_changed") {
+      console.log("speed test ice connection state changed");
+    }
+  }, []);
+
+  const speedTestForPlayWebRtcAdaptorErrorCallback = useCallback((error, message) => {
+    console.error("Error in speed test play: ", error, message);
+    setSpeedTestObjectFailed("There is an error('" + error + "'). Please try again later...");
+    stopSpeedTest();
+  }, []);
+
+  const processUpdatedStatsForPlaySpeedTest = useCallback((statsObj) => {
+    if (speedTestCounter.current === 0) {
+      statsList.current = []; // reset stats list if it is the first time
+    }
+    setSpeedTestObjectProgress(20 + (speedTestCounter.current * 20));
+
+    speedTestCounter.current = speedTestCounter.current + 1;
+    setAndFillPlayStatsList(statsObj);
+
+    if (speedTestCounter.current > 3 && statsList.current.length > 3) {
+      calculateThePlaySpeedTestResult();
+    } else {
+      setSpeedTestObjectProgress(20 + (speedTestCounter.current * 20));
+        let tempSpeedTestObject = {};
+        tempSpeedTestObject.message = speedTestObject.message;
+        tempSpeedTestObject.isfinished = false;
+        tempSpeedTestObject.isfailed = false;
+        tempSpeedTestObject.errorMessage = "";
+        tempSpeedTestObject.progressValue = 20 + (speedTestCounter.current * 20);
+        speedTestProgress.current = tempSpeedTestObject.progressValue;
+        setSpeedTestObject(tempSpeedTestObject);
+    }
+  }, []);
+
+  const setAndFillPlayStatsList = useCallback((obj) => {
+    let tempStatsList = statsList.current;
+    let tempStats = {};
+
+    tempStats.currentRoundTripTime = obj.currentRoundTripTime;
+    tempStats.packetsReceived = obj.packetsReceived;
+    tempStats.totalBytesReceivedCount = obj.totalBytesReceivedCount;
+    tempStats.framesReceived = obj.framesReceived;
+    tempStats.framesDropped = obj.framesDropped;
+    tempStats.startTime = obj.startTime;
+    tempStats.currentTimestamp = obj.currentTimestamp;
+    tempStats.firstBytesReceivedCount = obj.firstBytesReceivedCount;
+    tempStats.lastBytesReceived = obj.lastBytesReceived;
+    tempStats.videoPacketsLost = obj.videoPacketsLost;
+    tempStats.audioPacketsLost = obj.audioPacketsLost;
+    tempStats.inboundRtpList = obj.inboundRtpList;
+    tempStats.videoJitterAverageDelay = obj.videoJitterAverageDelay;
+    tempStats.audioJitterAverageDelay = obj.audioJitterAverageDelay;
+    tempStats.videoRoundTripTime = obj.videoRoundTripTime;
+    tempStats.audioRoundTripTime = obj.audioRoundTripTime;
+
+    tempStatsList.push(tempStats);
+    statsList.current = tempStatsList;
+  }, []);
+
+  function calculateThePlaySpeedTestResult() {
+    let stats = statsList.current[statsList.current.length - 1];
+    let oldStats = statsList.current[statsList.current.length - 2];
+
+    // Calculate total bytes received
+    let totalBytesReceived = stats.totalBytesReceivedCount;
+
+    // Calculate video frames received and frames dropped
+    let framesReceived = stats.framesReceived;
+    let framesDropped = stats.framesDropped;
+
+    // Calculate the time difference (in seconds)
+    let timeElapsed = (stats.currentTimestamp - stats.startTime) / 1000; // Convert ms to seconds
+
+    // Calculate incoming bitrate (bits per second)
+    let bytesReceivedDiff = stats.lastBytesReceived - stats.firstBytesReceivedCount;
+    let incomingBitrate = (bytesReceivedDiff * 8) / timeElapsed; // Convert bytes to bits
+
+    // Calculate packet loss
+    let videoPacketsLost = stats.videoPacketsLost;
+    let audioPacketsLost = stats.audioPacketsLost;
+
+    let totalPacketsLost = videoPacketsLost + audioPacketsLost;
+
+    // Calculate packet loss for the previous stats
+    let oldVideoPacketsLost = stats.videoPacketsLost;
+    let oldAudioPacketsLost = stats.audioPacketsLost;
+
+    let oldTotalPacketsLost = oldVideoPacketsLost + oldAudioPacketsLost;
+
+    let packageReceived = stats.inboundRtpList.find(item => item.trackIdentifier.startsWith('ARDAMSv')).packetsReceived + stats.inboundRtpList.find(item => item.trackIdentifier.startsWith('ARDAMSa')).packetsReceived;
+    let oldPackageReceived = oldStats.inboundRtpList.find(item => item.trackIdentifier.startsWith('ARDAMSv')).packetsReceived + oldStats.inboundRtpList.find(item => item.trackIdentifier.startsWith('ARDAMSa')).packetsReceived;
+
+    // Calculate the packet loss percentage
+    let packageLostPercentage = 0;
+    console.log("publishStats:", publishStats.current);
+    if (publishStats.current !== null) {
+        let deltaPackageLost = oldTotalPacketsLost - totalPacketsLost;
+        let deltaPackageReceived = oldPackageReceived - packageReceived;
+
+        if (deltaPackageLost > 0) {
+            packageLostPercentage = ((deltaPackageLost / parseInt(deltaPackageReceived)) * 100).toPrecision(3);
+        }
+    }
+
+    // Jitter calculation (average of video and audio jitter)
+    let videoJitter = stats.inboundRtpList.find(item => item.trackIdentifier.startsWith('ARDAMSv')).jitterBufferDelay;
+    let audioJitter = stats.inboundRtpList.find(item => item.trackIdentifier.startsWith('ARDAMSa')).jitterBufferDelay;
+
+    let avgJitter = (videoJitter + audioJitter) / 2;
+
+    let rtt = ((parseFloat(stats.videoRoundTripTime) + parseFloat(stats.audioRoundTripTime)) / 2).toPrecision(3);
+
+    // Frame drop rate
+    let frameDropRate = framesDropped / framesReceived * 100;
+
+    console.log("* Total bytes received: " + totalBytesReceived);
+    console.log("* Incoming bitrate: " + incomingBitrate.toFixed(2) + " bps");
+    console.log("* Total packets lost: " + totalPacketsLost);
+    console.log("* Frame drop rate: " + frameDropRate.toFixed(2) + "%");
+    console.log("* Average jitter: " + avgJitter.toFixed(2) + " ms");
+
+    let speedTestResult = {};
+
+    if (rtt > 0.15 || packageLostPercentage > 2.5 || frameDropRate > 5 || avgJitter > 100) {
+        console.log("-> Your connection quality is poor. You may experience interruptions");
+        speedTestResult.message = "Your connection quality is poor. You may experience interruptions";
+    } else if (rtt > 0.1 || packageLostPercentage > 1.5 || avgJitter > 50 || frameDropRate > 2.5) {
+        console.log("-> Your connection is moderate, occasional disruptions may occur");
+        speedTestResult.message = "Your connection is moderate, occasional disruptions may occur";
+    } else {
+        console.log("-> Your connection is great");
+        speedTestResult.message = "Your connection is Great!";
+    }
+
+    speedTestResult.isfailed = false;
+    speedTestResult.errorMessage = "";
+    speedTestResult.progressValue = 100;
+
+    speedTestResult.isfinished = true;
+    speedTestProgress.current = 100;
+    setSpeedTestObject(speedTestResult);
+
+    stopSpeedTest();
+}
+  return {
+    startSpeedTest,
+    stopSpeedTest,
+    speedTestInProgress,
+    speedTestProgress,
+    speedTestStreamId,
+    speedTestObject,
+    setSpeedTestObject,
+    setAndFillPlayStatsList,
+    setAndFillPublishStatsList,
+    speedTestCounter,
+    statsList,
+    calculateThePlaySpeedTestResult,
+    processUpdatedStatsForPlaySpeedTest,
+    setSpeedTestObjectFailed,
+    setSpeedTestObjectProgress,
+  };
+} 
\ No newline at end of file
diff --git a/react/src/pages/AntMedia.js b/react/src/pages/AntMedia.js
index 62ea1ad9..00479bdc 100644
--- a/react/src/pages/AntMedia.js
+++ b/react/src/pages/AntMedia.js
@@ -24,6 +24,7 @@ import leaveRoomSound from 'static/sounds/leave-sound.mp3';
 import PublisherRequestListDrawer from "../Components/PublisherRequestListDrawer";
 import { WebinarRoles } from "../WebinarRoles";
 import Stack from "@mui/material/Stack";
+import useSpeedTest from "../hooks/useSpeedTest";
 
 // UnitTestContext is used to pass the globals object to the unit tests
 // don't use it in the production code
@@ -430,21 +431,6 @@ function AntMedia(props) {
         }
         return result;
     }, []);
-
-    // speed test related states
-    const speedTestStreamId = React.useRef(makeid(20));
-    const speedTestForPublishWebRtcAdaptor = React.useRef(null);
-    const [speedTestObject, setSpeedTestObject] = React.useState({
-        message: "Please wait while we are testing your connection speed",
-        isfinished: false,
-        isfailed: false,
-        errorMessage: "",
-        progressValue: 10
-    });
-    const speedTestProgress = React.useRef(0);
-    const speedTestPlayStarted = React.useRef(false);
-    const speedTestCounter = React.useRef(0);
-    const speedTestForPlayWebRtcAdaptor = React.useRef(null);
     const statsList = React.useRef([]);
     const isFirstRunForPlayOnly = React.useRef(true);
 
@@ -498,424 +484,32 @@ function AntMedia(props) {
 
     }
 
-    /*
-      * This function performs the following tasks:
-      * 1. It creates two new WebRTCAdaptor instances for publish and play.
-      * 2. If the user is in playOnly mode, instead of using camera and microphone, it uses the video element for publish.
-     */
-    function startSpeedTest() {
-        //TODO: this speed test should be refactored and be thought again
-        if (isPlayOnly === "true" || isPlayOnly === true) {
-            createSpeedTestForPlayWebRtcAdaptor();
-        } else {
-            createSpeedTestForPublishWebRtcAdaptor();
-        }
-        setTimeout(() => {
-            if (speedTestProgress.current < 40) {
-                //it means that it's stuck before publish started
-                stopSpeedTest();
-                setSpeedTestObjectFailed("Speed test failed. It may be due to firewall, wi-fi or network restrictions. Change your network or Try again ");
-            }
-        }, 15000); //it tooks about 20 seconds to finish the test, if it's less 40, it means it's stuck
-    }
-
-    function stopSpeedTest() {
-        if (speedTestForPublishWebRtcAdaptor.current) {
-            speedTestForPublishWebRtcAdaptor.current.stop("speedTestStream" + speedTestStreamId.current);
-            speedTestForPublishWebRtcAdaptor.current.closeStream();
-            speedTestForPublishWebRtcAdaptor.current.closeWebSocket();
-        }
-        if (speedTestForPlayWebRtcAdaptor.current) {
-            speedTestForPlayWebRtcAdaptor.current.stop("speedTestSampleStream");
-        }
-        speedTestForPublishWebRtcAdaptor.current = null;
-        speedTestForPlayWebRtcAdaptor.current = null;
-
-        //we need to listen device changes with main webRTCAdaptor
-        webRTCAdaptor.mediaManager?.trackDeviceChange();
-    }
-
-    function createSpeedTestForPublishWebRtcAdaptor() {
-        speedTestForPublishWebRtcAdaptor.current = new WebRTCAdaptor({
-            websocket_url: websocketURL,
-            mediaConstraints: { video: true, audio: false },
-            sdp_constraints: {
-                OfferToReceiveAudio: false, OfferToReceiveVideo: false,
-            },
-            peerconnection_config: peerconnection_config,
-            debug: true,
-            callback: speedTestForPublishWebRtcAdaptorInfoCallback,
-            callbackError: speedTestForPublishWebRtcAdaptorErrorCallback,
-            purposeForTest: "publish-speed-test"
-        })
-
-    }
-
-    function speedTestForPublishWebRtcAdaptorInfoCallback(info, obj) {
-        if (info === "initialized") {
-            speedTestCounter.current = 0;
-            setSpeedTestObjectProgress(10);
-            speedTestForPublishWebRtcAdaptor.current.publish("speedTestStream" + speedTestStreamId.current, token, subscriberId, subscriberCode, "speedTestStream" + speedTestStreamId.current, "", "")
-        }
-        else if (info === "publish_started") {
-            speedTestCounter.current = 0;
-            console.log("speed test publish started");
-            setSpeedTestObjectProgress(20);
-            speedTestForPublishWebRtcAdaptor.current.enableStats("speedTestStream" + speedTestStreamId.current);
-        }
-        else if (info === "updated_stats") {
-            if (speedTestCounter.current === 0) {
-                statsList.current = []; // reset stats list if it is the first time
-            }
-            setSpeedTestObjectProgress(20 + (speedTestCounter.current * 20));
-
-            speedTestCounter.current = speedTestCounter.current + 1;
-            setAndFillPublishStatsList(obj);
-
-            if (speedTestCounter.current > 3 && statsList.current.length > 3) {
-                calculateThePublishSpeedTestResult();
-            } else {
-                setSpeedTestObjectProgress(20 + (speedTestCounter.current * 20));
-            }
-        }
-        else if (info === "ice_connection_state_changed") {
-            console.log("speed test ice connection state changed")
-        }
-    }
-
-    /*
-
-     */
-
-    function setAndFillPlayStatsList(obj) {
-        console.log("obj", obj);
-        let tempStatsList = statsList.current;
-        let tempStats = {};
-
-        tempStats.currentRoundTripTime = obj.currentRoundTripTime;
-
-        tempStats.packetsReceived = obj.packetsReceived;
-
-        tempStats.totalBytesReceivedCount = obj.totalBytesReceivedCount;
-
-        tempStats.framesReceived = obj.framesReceived;
-        tempStats.framesDropped = obj.framesDropped;
-
-        tempStats.startTime = obj.startTime;
-        tempStats.currentTimestamp = obj.currentTimestamp;
-
-        tempStats.firstBytesReceivedCount = obj.firstBytesReceivedCount;
-        tempStats.lastBytesReceived = obj.lastBytesReceived;
-
-        tempStats.videoPacketsLost = obj.videoPacketsLost;
-        tempStats.audioPacketsLost = obj.audioPacketsLost;
-
-        tempStats.inboundRtpList = obj.inboundRtpList;
-
-        tempStats.videoJitterAverageDelay = obj.videoJitterAverageDelay;
-        tempStats.audioJitterAverageDelay = obj.audioJitterAverageDelay;
-
-        tempStats.videoRoundTripTime = obj.videoRoundTripTime;
-        tempStats.audioRoundTripTime = obj.audioRoundTripTime;
-
-        tempStatsList.push(tempStats);
-        statsList.current = tempStatsList;
-    }
-
-    function setAndFillPublishStatsList(obj) {
-        console.log("obj", obj);
-        let tempStatsList = statsList.current;
-        let tempStats = {};
-        tempStats.videoRoundTripTime = obj.videoRoundTripTime;
-        tempStats.audioRoundTripTime = obj.audioRoundTripTime;
-        tempStats.videoPacketsLost = obj.videoPacketsLost;
-        tempStats.totalVideoPacketsSent = obj.totalVideoPacketsSent;
-        tempStats.totalAudioPacketsSent = obj.totalAudioPacketsSent;
-        tempStats.audioPacketsLost = obj.audioPacketsLost;
-        tempStats.videoJitter = obj.videoJitter;
-        tempStats.audioJitter = obj.audioJitter;
-        tempStats.currentOutgoingBitrate = obj.currentOutgoingBitrate;
-        tempStatsList.push(tempStats);
-        statsList.current = tempStatsList;
-    }
-
-    function setSpeedTestObjectFailed(errorMessage) {
-        let tempSpeedTestObject = {};
-        tempSpeedTestObject.message = errorMessage;
-        tempSpeedTestObject.isfinished = false;
-        tempSpeedTestObject.isfailed = true;
-        tempSpeedTestObject.errorMessage = errorMessage;
-        tempSpeedTestObject.progressValue = 0;
-        speedTestProgress.current = tempSpeedTestObject.progressValue;
-
-        setSpeedTestObject(tempSpeedTestObject);
-    }
-
-    function setSpeedTestObjectProgress(progressValue) {
-        // if progress value is more than 100, it means that speed test is failed, and we can not get or set the stat list properly
-
-        //TODO: It's just a insurance to not encounter this case. It's put there for a workaround solution in production for fakeeh. Remove it later - mekya
-        if (progressValue > 100) {
-            // we need to stop the speed test and set the speed test object as failed
-            stopSpeedTest();
-            setSpeedTestObjectFailed("Speed test failed. It may be due to firewall, wi-fi or network restrictions. Change your network or Try again ");
-            return;
-        }
-        let tempSpeedTestObject = {};
-        tempSpeedTestObject.message = speedTestObject.message;
-        tempSpeedTestObject.isfinished = false;
-        tempSpeedTestObject.isfailed = false;
-        tempSpeedTestObject.errorMessage = "";
-        tempSpeedTestObject.progressValue = progressValue;
-        speedTestProgress.current = tempSpeedTestObject.progressValue;
-        setSpeedTestObject(tempSpeedTestObject);
-    }
-
-    function calculateThePublishSpeedTestResult() {
-        let updatedStats = {};
-
-        updatedStats.videoRoundTripTime = parseFloat(statsList.current[statsList.current.length - 1].videoRoundTripTime) // we can use the last value
-        updatedStats.videoRoundTripTime = (updatedStats.videoRoundTripTime === -1) ? 0 : updatedStats.videoRoundTripTime;
-
-        updatedStats.audioRoundTripTime = parseFloat(statsList.current[statsList.current.length - 1].audioRoundTripTime) // we can use the last value
-        updatedStats.audioRoundTripTime = (updatedStats.audioRoundTripTime === -1) ? 0 : updatedStats.audioRoundTripTime;
-
-        updatedStats.videoPacketsLost = parseInt(statsList.current[statsList.current.length - 1].videoPacketsLost)
-            + parseInt(statsList.current[statsList.current.length - 2].videoPacketsLost)
-            + parseInt(statsList.current[statsList.current.length - 3].videoPacketsLost);
-
-        updatedStats.videoPacketsLost = (updatedStats.videoPacketsLost < 0) ? 0 : updatedStats.videoPacketsLost;
-
-        updatedStats.totalVideoPacketsSent = parseInt(statsList.current[statsList.current.length - 1].totalVideoPacketsSent)
-            + parseInt(statsList.current[statsList.current.length - 2].totalVideoPacketsSent)
-            + parseInt(statsList.current[statsList.current.length - 3].totalVideoPacketsSent);
-
-        updatedStats.totalVideoPacketsSent = (updatedStats.totalVideoPacketsSent < 0) ? 0 : updatedStats.totalVideoPacketsSent;
-
-        updatedStats.audioPacketsLost = parseInt(statsList.current[statsList.current.length - 1].audioPacketsLost)
-            + parseInt(statsList.current[statsList.current.length - 2].audioPacketsLost)
-            + parseInt(statsList.current[statsList.current.length - 3].audioPacketsLost);
-
-        updatedStats.totalAudioPacketsSent = parseInt(statsList.current[statsList.current.length - 1].totalAudioPacketsSent)
-            + parseInt(statsList.current[statsList.current.length - 2].totalAudioPacketsSent)
-            + parseInt(statsList.current[statsList.current.length - 3].totalAudioPacketsSent);
-
-        updatedStats.totalAudioPacketsSent = (updatedStats.totalAudioPacketsSent < 0) ? 0 : updatedStats.totalAudioPacketsSent;
-
-        updatedStats.audioPacketsLost = (updatedStats.audioPacketsLost < 0) ? 0 : updatedStats.audioPacketsLost;
-
-        updatedStats.videoJitter = (parseFloat(statsList.current[statsList.current.length - 1].videoJitter) + parseFloat(statsList.current[statsList.current.length - 2].videoJitter)) / 2.0;
-        updatedStats.videoJitter = (updatedStats.videoJitter === -1) ? 0 : updatedStats.videoJitter;
-
-        updatedStats.audioJitter = (parseFloat(statsList.current[statsList.current.length - 1].audioJitter) + parseFloat(statsList.current[statsList.current.length - 2].audioJitter)) / 2.0;
-        updatedStats.audioJitter = (updatedStats.audioJitter === -1) ? 0 : updatedStats.audioJitter;
-
-        updatedStats.currentOutgoingBitrate = parseInt(statsList.current[statsList.current.length - 1].currentOutgoingBitrate) // we can use the last value
-        updatedStats.currentOutgoingBitrate = (updatedStats.currentOutgoingBitrate === -1) ? 0 : updatedStats.currentOutgoingBitrate;
-
-        let rtt = ((parseFloat(updatedStats.videoRoundTripTime) + parseFloat(updatedStats.audioRoundTripTime)) / 2).toPrecision(3);
-        let packetLost = parseInt(updatedStats.videoPacketsLost) + parseInt(updatedStats.audioPacketsLost);
-        let packetLostPercentage = ((updatedStats.videoPacketsLost + updatedStats.audioPacketsLost) / (updatedStats.totalVideoPacketsSent + updatedStats.totalAudioPacketsSent)) * 100
-        let jitter = ((parseFloat(updatedStats.videoJitter) + parseInt(updatedStats.audioJitter)) / 2).toPrecision(3);
-        let outgoingBitrate = parseInt(updatedStats.currentOutgoingBitrate);
-        let bandwidth = parseInt(speedTestForPublishWebRtcAdaptor.current.mediaManager.bandwidth);
-        console.log("* rtt: " + rtt);
-        console.log("* packetLost: " + packetLost);
-        console.log("* totalPacketSent: " + (updatedStats.totalVideoPacketsSent + updatedStats.totalAudioPacketsSent));
-        console.log("* packetLostPercentage: " + packetLostPercentage);
-        console.log("* jitter: " + jitter);
-        console.log("* outgoingBitrate: " + outgoingBitrate);
-        console.log("* bandwidth: " + bandwidth);
-
-        let speedTestResult = {};
-
-        if (rtt >= 0.2 || packetLostPercentage >= 3.5 || jitter >= 0.2) {
-            console.log("-> Your connection quality is poor. You may experience interruptions");
-            speedTestResult.message = "Your connection quality is poor. You may experience interruptions";
-        } else if (rtt >= 0.1 || packetLostPercentage >= 2 || jitter >= 0.08) {
-            console.log("-> Your connection is moderate, occasional disruptions may occur");
-            speedTestResult.message = "Your connection is moderate, occasional disruptions may occur";
-        } else if (rtt >= 0.03 || jitter >= 0.02 || packetLostPercentage >= 1) {
-            console.log("-> Your connection is good.");
-            speedTestResult.message = "Your connection is Good.";
-        } else {
-            console.log("-> Your connection is great");
-            speedTestResult.message = "Your connection is Great!";
-        }
-
-        speedTestResult.isfailed = false;
-        speedTestResult.errorMessage = "";
-        speedTestResult.progressValue = 100;
-
-        speedTestResult.isfinished = true;
-        speedTestProgress.current = speedTestResult.progressValue;
-        setSpeedTestObject(speedTestResult);
-
-        stopSpeedTest();
-    }
-
-    function calculateThePlaySpeedTestResult() {
-        let stats = statsList.current[statsList.current.length - 1];
-        let oldStats = statsList.current[statsList.current.length - 2];
-
-        // Calculate total bytes received
-        let totalBytesReceived = stats.totalBytesReceivedCount;
-
-        // Calculate video frames received and frames dropped
-        let framesReceived = stats.framesReceived;
-        let framesDropped = stats.framesDropped;
-
-        // Calculate the time difference (in seconds)
-        let timeElapsed = (stats.currentTimestamp - stats.startTime) / 1000; // Convert ms to seconds
-
-        // Calculate incoming bitrate (bits per second)
-        let bytesReceivedDiff = stats.lastBytesReceived - stats.firstBytesReceivedCount;
-        let incomingBitrate = (bytesReceivedDiff * 8) / timeElapsed; // Convert bytes to bits
-
-        // Calculate packet loss
-        let videoPacketsLost = stats.videoPacketsLost;
-        let audioPacketsLost = stats.audioPacketsLost;
-
-        let totalPacketsLost = videoPacketsLost + audioPacketsLost;
-
-        // Calculate packet loss for the previous stats
-        let oldVideoPacketsLost = stats.videoPacketsLost;
-        let oldAudioPacketsLost = stats.audioPacketsLost;
-
-        let oldTotalPacketsLost = oldVideoPacketsLost + oldAudioPacketsLost;
-
-        let packageReceived = stats.inboundRtpList.find(item => item.trackIdentifier.startsWith('ARDAMSv')).packetsReceived + stats.inboundRtpList.find(item => item.trackIdentifier.startsWith('ARDAMSa')).packetsReceived;
-        let oldPackageReceived = oldStats.inboundRtpList.find(item => item.trackIdentifier.startsWith('ARDAMSv')).packetsReceived + oldStats.inboundRtpList.find(item => item.trackIdentifier.startsWith('ARDAMSa')).packetsReceived;
-
-        // Calculate the packet loss percentage
-        let packageLostPercentage = 0;
-        console.log("publishStats:", publishStats.current);
-        if (publishStats.current !== null) {
-            let deltaPackageLost = oldTotalPacketsLost - totalPacketsLost;
-            let deltaPackageReceived = oldPackageReceived - packageReceived;
-
-            if (deltaPackageLost > 0) {
-                packageLostPercentage = ((deltaPackageLost / parseInt(deltaPackageReceived)) * 100).toPrecision(3);
-            }
-        }
-
-        // Jitter calculation (average of video and audio jitter)
-        let videoJitter = stats.inboundRtpList.find(item => item.trackIdentifier.startsWith('ARDAMSv')).jitterBufferDelay;
-        let audioJitter = stats.inboundRtpList.find(item => item.trackIdentifier.startsWith('ARDAMSa')).jitterBufferDelay;
-
-        let avgJitter = (videoJitter + audioJitter) / 2;
-
-        let rtt = ((parseFloat(stats.videoRoundTripTime) + parseFloat(stats.audioRoundTripTime)) / 2).toPrecision(3);
-
-        // Frame drop rate
-        let frameDropRate = framesDropped / framesReceived * 100;
-
-        console.log("* Total bytes received: " + totalBytesReceived);
-        console.log("* Incoming bitrate: " + incomingBitrate.toFixed(2) + " bps");
-        console.log("* Total packets lost: " + totalPacketsLost);
-        console.log("* Frame drop rate: " + frameDropRate.toFixed(2) + "%");
-        console.log("* Average jitter: " + avgJitter.toFixed(2) + " ms");
-
-        let speedTestResult = {};
-
-        if (rtt > 0.15 || packageLostPercentage > 2.5 || frameDropRate > 5 || avgJitter > 100) {
-            console.log("-> Your connection quality is poor. You may experience interruptions");
-            speedTestResult.message = "Your connection quality is poor. You may experience interruptions";
-        } else if (rtt > 0.1 || packageLostPercentage > 1.5 || avgJitter > 50 || frameDropRate > 2.5) {
-            console.log("-> Your connection is moderate, occasional disruptions may occur");
-            speedTestResult.message = "Your connection is moderate, occasional disruptions may occur";
-        } else {
-            console.log("-> Your connection is great");
-            speedTestResult.message = "Your connection is Great!";
-        }
-
-        speedTestResult.isfailed = false;
-        speedTestResult.errorMessage = "";
-        speedTestResult.progressValue = 100;
-
-        speedTestResult.isfinished = true;
-        speedTestProgress.current = speedTestResult.progressValue;
-        setSpeedTestObject(speedTestResult);
-
-        stopSpeedTest();
-    }
-
-
-    function speedTestForPublishWebRtcAdaptorErrorCallback(error, message) {
-        console.log("error from speed test webrtc adaptor callback")
-        //some of the possible errors, NotFoundError, SecurityError,PermissionDeniedError
-        console.log("error:" + error + " message:" + message);
-
-        setSpeedTestObjectFailed("There is an error('" + error + "'). Please try again later...");
-        stopSpeedTest();
-    }
-
-    function createSpeedTestForPlayWebRtcAdaptor() {
-        speedTestPlayStarted.current = false;
-        speedTestForPlayWebRtcAdaptor.current = new WebRTCAdaptor({
-            websocket_url: websocketURL,
-            mediaConstraints: { video: false, audio: false },
-            playOnly: true,
-            sdp_constraints: {
-                OfferToReceiveAudio: false, OfferToReceiveVideo: false,
-            },
-            peerconnection_config: peerconnection_config,
-            debug: true,
-            callback: speedTestForPlayWebRtcAdaptorInfoCallback,
-            callbackError: speedTestForPlayWebRtcAdaptorErrorCallback,
-            purposeForTest: "play-speed-test"
-        })
-    }
-
-    function speedTestForPlayWebRtcAdaptorInfoCallback(info, obj) {
-        if (info === "initialized") {
-            speedTestPlayStarted.current = false;
-            speedTestForPlayWebRtcAdaptor.current.play("speedTestSampleStream", "", "", [], "", "", "");
-        } else if (info === "play_started") {
-            console.log("speed test play started")
-            speedTestPlayStarted.current = true;
-            setSpeedTestObjectProgress(20);
-            speedTestForPlayWebRtcAdaptor.current?.enableStats("speedTestSampleStream");
-        }
-        else if (info === "updated_stats") {
-            processUpdatedStatsForPlaySpeedTest(obj);
-        } else if (info === "ice_connection_state_changed") {
-            console.log("speed test ice connection state changed")
-        }
-    }
-
-    function speedTestForPlayWebRtcAdaptorErrorCallback(error, message) {
-        console.log("error from speed test webrtc adaptor callback")
-        //some of the possible errors, NotFoundError, SecurityError,PermissionDeniedError
-        console.log("error:" + error + " message:" + message);
-
-        setSpeedTestObjectFailed("There is an error('" + error + "'). Please try again later...");
-
-        stopSpeedTest();
-    }
-
-    function processUpdatedStatsForPlaySpeedTest(statsObj) {
-        if (speedTestCounter.current === 0) {
-            statsList.current = []; // reset stats list if it is the first time
-        }
-        setSpeedTestObjectProgress(20 + (speedTestCounter.current * 20));
-
-        speedTestCounter.current = speedTestCounter.current + 1;
-        setAndFillPlayStatsList(statsObj);
-
-        if (speedTestCounter.current > 3 && statsList.current.length > 3) {
-            calculateThePlaySpeedTestResult();
-        } else {
-            let tempSpeedTestObject = {};
-            tempSpeedTestObject.message = speedTestObject.message;
-            tempSpeedTestObject.isfinished = false;
-            tempSpeedTestObject.isfailed = false;
-            tempSpeedTestObject.errorMessage = "";
-            tempSpeedTestObject.progressValue = 20 + (speedTestCounter.current * 20);
-            speedTestProgress.current = tempSpeedTestObject.progressValue;
-            setSpeedTestObject(tempSpeedTestObject);
-        }
-    }
+     // Use the custom hook for speed testing
+     const {
+        startSpeedTest,
+        stopSpeedTest,
+        speedTestResults,
+        speedTestInProgress,
+        speedTestProgress,
+        speedTestStreamId,
+        speedTestCounter,
+        speedTestObject,
+        setSpeedTestObject,
+        setSpeedTestObjectFailed,
+        setSpeedTestObjectProgress,
+        statsList: speedTestStatsList,
+        setAndFillPlayStatsList,
+        setAndFillPublishStatsList,
+        calculateThePlaySpeedTestResult,
+        processUpdatedStatsForPlaySpeedTest
+    } = useSpeedTest({
+        websocketURL,
+        peerconnection_config,
+        token,
+        subscriberId,
+        subscriberCode,
+        isPlayOnly
+    });
 
     function checkAndUpdateVideoAudioSources() {
         if (isPlayOnly) {
@@ -3344,7 +2938,12 @@ function AntMedia(props) {
                     speedTestStreamId,
                     startSpeedTest,
                     stopSpeedTest,
-                    statsList,
+                    speedTestStatsList,
+                    setAndFillPlayStatsList,
+                    setAndFillPublishStatsList,
+                    calculateThePlaySpeedTestResult,
+                    processUpdatedStatsForPlaySpeedTest,
+                    speedTestCounter,
                     getTrackStats,
                     isBroadcasting,
                     playStats,
@@ -3358,13 +2957,8 @@ function AntMedia(props) {
                     checkAndUpdateVideoAudioSourcesForPublishSpeedTest,
                     fetchImageAsBlob,
                     setAndEnableVirtualBackgroundImage,
-                    setAndFillPlayStatsList,
-                    setAndFillPublishStatsList,
                     setSpeedTestObjectFailed,
                     setSpeedTestObjectProgress,
-                    calculateThePlaySpeedTestResult,
-                    processUpdatedStatsForPlaySpeedTest,
-                    speedTestCounter,
                     setRoomName,
                     setPublishStreamId,
                     settings,

From be65da182e4f247150ec8ec59e2822c8b968a749 Mon Sep 17 00:00:00 2001
From: golgetahir <tahir.golge@gmail.com>
Date: Sat, 8 Mar 2025 23:37:30 +0300
Subject: [PATCH 11/11] Increase coverage

---
 .../src/__tests__/hooks/useSpeedTest.test.js  | 375 ++++++++++++++++++
 react/src/hooks/useSpeedTest.js               |   4 +-
 2 files changed, 378 insertions(+), 1 deletion(-)

diff --git a/react/src/__tests__/hooks/useSpeedTest.test.js b/react/src/__tests__/hooks/useSpeedTest.test.js
index f9327d0d..b3f60802 100644
--- a/react/src/__tests__/hooks/useSpeedTest.test.js
+++ b/react/src/__tests__/hooks/useSpeedTest.test.js
@@ -472,4 +472,379 @@ describe('useSpeedTest Hook', () => {
       progressValue: 60
     });
   });
+
+  it('creates WebRTC adaptor for play when isPlayOnly is true', () => {
+    const playOnlyProps = {
+      ...defaultProps,
+      isPlayOnly: true
+    };
+
+    const { result } = renderHook(() => useSpeedTest(playOnlyProps));
+
+    act(() => {
+      result.current.startSpeedTest();
+    });
+
+    expect(result.current.speedTestInProgress).toBe(true);
+    // WebRTCAdaptor constructor should be called with play-specific parameters
+    expect(require('@antmedia/webrtc_adaptor').WebRTCAdaptor).toHaveBeenCalledWith(
+      expect.objectContaining({
+        purposeForTest: 'play-speed-test'
+      })
+    );
+  });
+
+  it('creates WebRTC adaptor for publish when isPlayOnly is false', () => {
+    const { result } = renderHook(() => useSpeedTest(defaultProps));
+
+    act(() => {
+      result.current.startSpeedTest();
+    });
+
+    expect(result.current.speedTestInProgress).toBe(true);
+    // WebRTCAdaptor constructor should be called with publish-specific parameters
+    expect(require('@antmedia/webrtc_adaptor').WebRTCAdaptor).toHaveBeenCalledWith(
+      expect.objectContaining({
+        purposeForTest: 'publish-speed-test'
+      })
+    );
+  });
+
+  it('handles initialized callback for publish adaptor', () => {
+    const { result } = renderHook(() => useSpeedTest(defaultProps));
+    
+    // Capture the callback function when WebRTCAdaptor is constructed
+    const mockCallback = jest.fn();
+    require('@antmedia/webrtc_adaptor').WebRTCAdaptor.mockImplementationOnce(config => {
+      mockCallback.mockImplementation(config.callback);
+      return {
+        publish: jest.fn(),
+        enableStats: jest.fn(),
+        stop: jest.fn(),
+        closeStream: jest.fn(),
+        closeWebSocket: jest.fn()
+      };
+    });
+    
+    act(() => {
+      result.current.startSpeedTest();
+    });
+    
+    // Simulate the initialized callback
+    act(() => {
+      result.current.speedTestForPublishWebRtcAdaptorInfoCallback('initialized');
+    });
+    
+    expect(result.current.speedTestCounter.current).toBe(0);
+    expect(result.current.speedTestObject.progressValue).toBe(10);
+  });
+
+  it('handles publish_started callback for publish adaptor', () => {
+    const { result } = renderHook(() => useSpeedTest(defaultProps));
+    
+    act(() => {
+      result.current.startSpeedTest();
+    });
+    
+    // Directly test the callback handler
+    act(() => {
+      result.current.speedTestForPublishWebRtcAdaptorInfoCallback('publish_started');
+    });
+    
+    expect(result.current.speedTestCounter.current).toBe(0);
+    expect(result.current.speedTestObject.progressValue).toBe(20);
+  });
+
+  it('handles play_started callback for play adaptor', () => {
+    const { result } = renderHook(() => useSpeedTest({...defaultProps, isPlayOnly: true}));
+    
+    act(() => {
+      result.current.startSpeedTest();
+    });
+    
+    // Mock the WebRTCAdaptor callback directly
+    const webRtcAdaptor = require('@antmedia/webrtc_adaptor').WebRTCAdaptor.mock.instances[0];
+    // Call the callback function that was passed to WebRTCAdaptor
+    const callbackFunction = require('@antmedia/webrtc_adaptor').WebRTCAdaptor.mock.calls[0][0].callback;
+    
+    act(() => {
+      callbackFunction('play_started');
+    });
+    
+    expect(result.current.speedTestObject.progressValue).toBe(20);
+  });
+
+  it('handles updated_stats callback for publish adaptor with sufficient iterations', () => {
+    const { result } = renderHook(() => useSpeedTest(defaultProps));
+    
+    act(() => {
+      result.current.startSpeedTest();
+    });
+    
+    // Setup the scenario where we already have enough stats
+    result.current.speedTestCounter.current = 3;
+    result.current.statsList.current = [{}, {}, {}, {}];
+    
+    // Call the callback function that was passed to WebRTCAdaptor
+    const callbackFunction = require('@antmedia/webrtc_adaptor').WebRTCAdaptor.mock.calls[0][0].callback;
+    
+    act(() => {
+      callbackFunction('updated_stats', {});
+    });
+    
+    // The test passes if we don't get an error, as the actual implementation would call calculateThePublishSpeedTestResult
+  });
+
+  it('handles error callback for publish adaptor', () => {
+    const { result } = renderHook(() => useSpeedTest(defaultProps));
+    
+    act(() => {
+      result.current.startSpeedTest();
+    });
+    
+    // Call the error callback function that was passed to WebRTCAdaptor
+    const errorCallbackFunction = require('@antmedia/webrtc_adaptor').WebRTCAdaptor.mock.calls[0][0].callbackError;
+    
+    act(() => {
+      errorCallbackFunction('test-error', 'test-message');
+    });
+    
+    expect(result.current.speedTestObject.isfailed).toBe(true);
+    expect(result.current.speedTestObject.errorMessage).toContain('test-error');
+  });
+
+  it('handles error callback for play adaptor', () => {
+    const { result } = renderHook(() => useSpeedTest({...defaultProps, isPlayOnly: true}));
+    
+    act(() => {
+      result.current.startSpeedTest();
+    });
+    
+    // Call the error callback function that was passed to WebRTCAdaptor
+    const errorCallbackFunction = require('@antmedia/webrtc_adaptor').WebRTCAdaptor.mock.calls[0][0].callbackError;
+    
+    act(() => {
+      errorCallbackFunction('test-error', 'test-message');
+    });
+    
+    expect(result.current.speedTestObject.isfailed).toBe(true);
+    expect(result.current.speedTestObject.errorMessage).toContain('test-error');
+  });
+
+  it('calculates publish speed test result with good connection', () => {
+    const { result } = renderHook(() => useSpeedTest(defaultProps));
+    
+    act(() => {
+      result.current.startSpeedTest();
+    });
+    
+    // Prepare mock stats for a good connection
+    result.current.statsList.current = [
+      {
+        videoRoundTripTime: '0.02',
+        audioRoundTripTime: '0.02',
+        videoPacketsLost: '0',
+        totalVideoPacketsSent: '1000',
+        totalAudioPacketsSent: '1000',
+        audioPacketsLost: '0',
+        videoJitter: '0.01',
+        audioJitter: '0.01',
+        currentOutgoingBitrate: '500000'
+      },
+      {
+        videoRoundTripTime: '0.02',
+        audioRoundTripTime: '0.02',
+        videoPacketsLost: '0',
+        totalVideoPacketsSent: '1000',
+        totalAudioPacketsSent: '1000',
+        audioPacketsLost: '0',
+        videoJitter: '0.01',
+        audioJitter: '0.01',
+        currentOutgoingBitrate: '500000'
+      },
+      {
+        videoRoundTripTime: '0.02',
+        audioRoundTripTime: '0.02',
+        videoPacketsLost: '0',
+        totalVideoPacketsSent: '1000',
+        totalAudioPacketsSent: '1000',
+        audioPacketsLost: '0',
+        videoJitter: '0.01',
+        audioJitter: '0.01',
+        currentOutgoingBitrate: '500000'
+      }
+    ];
+    
+    // Call the function via the callback to ensure it's properly called
+    const callbackFunction = require('@antmedia/webrtc_adaptor').WebRTCAdaptor.mock.calls[0][0].callback;
+    
+    act(() => {
+      // Simulate a scenario that would trigger calculateThePublishSpeedTestResult
+      result.current.speedTestCounter.current = 4;
+      callbackFunction('updated_stats', {});
+    });
+    
+    // Test that the calculation happened correctly
+    expect(result.current.speedTestObject.isfinished).toBe(true);
+    expect(result.current.speedTestObject.progressValue).toBe(100);
+  });
+
+  it('calculates publish speed test result with moderate connection', () => {
+    const { result } = renderHook(() => useSpeedTest(defaultProps));
+    
+    act(() => {
+      result.current.startSpeedTest();
+    });
+    
+    // Prepare mock stats for a moderate connection
+    result.current.statsList.current = [
+      {
+        videoRoundTripTime: '0.15',
+        audioRoundTripTime: '0.15',
+        videoPacketsLost: '20',
+        totalVideoPacketsSent: '1000',
+        totalAudioPacketsSent: '1000',
+        audioPacketsLost: '20',
+        videoJitter: '0.09',
+        audioJitter: '0.09',
+        currentOutgoingBitrate: '300000'
+      },
+      {
+        videoRoundTripTime: '0.15',
+        audioRoundTripTime: '0.15',
+        videoPacketsLost: '20',
+        totalVideoPacketsSent: '1000',
+        totalAudioPacketsSent: '1000',
+        audioPacketsLost: '20',
+        videoJitter: '0.09',
+        audioJitter: '0.09',
+        currentOutgoingBitrate: '300000'
+      },
+      {
+        videoRoundTripTime: '0.15',
+        audioRoundTripTime: '0.15',
+        videoPacketsLost: '20',
+        totalVideoPacketsSent: '1000',
+        totalAudioPacketsSent: '1000',
+        audioPacketsLost: '20',
+        videoJitter: '0.09',
+        audioJitter: '0.09',
+        currentOutgoingBitrate: '300000'
+      }
+    ];
+    
+    act(() => {
+      result.current.calculateThePublishSpeedTestResult();
+    });
+    
+    expect(result.current.speedTestObject.message).toBe('Your connection is moderate, occasional disruptions may occur');
+    expect(result.current.speedTestObject.isfinished).toBe(true);
+    expect(result.current.speedTestObject.progressValue).toBe(100);
+  });
+
+  it('calculates publish speed test result with poor connection', () => {
+    const { result } = renderHook(() => useSpeedTest(defaultProps));
+    
+    act(() => {
+      result.current.startSpeedTest();
+    });
+    
+    // Prepare mock stats for a poor connection
+    result.current.statsList.current = [
+      {
+        videoRoundTripTime: '0.3',
+        audioRoundTripTime: '0.3',
+        videoPacketsLost: '50',
+        totalVideoPacketsSent: '1000',
+        totalAudioPacketsSent: '1000',
+        audioPacketsLost: '50',
+        videoJitter: '0.25',
+        audioJitter: '0.25',
+        currentOutgoingBitrate: '150000'
+      },
+      {
+        videoRoundTripTime: '0.3',
+        audioRoundTripTime: '0.3',
+        videoPacketsLost: '50',
+        totalVideoPacketsSent: '1000',
+        totalAudioPacketsSent: '1000',
+        audioPacketsLost: '50',
+        videoJitter: '0.25',
+        audioJitter: '0.25',
+        currentOutgoingBitrate: '150000'
+      },
+      {
+        videoRoundTripTime: '0.3',
+        audioRoundTripTime: '0.3',
+        videoPacketsLost: '50',
+        totalVideoPacketsSent: '1000',
+        totalAudioPacketsSent: '1000',
+        audioPacketsLost: '50',
+        videoJitter: '0.25',
+        audioJitter: '0.25',
+        currentOutgoingBitrate: '150000'
+      }
+    ];
+    
+    act(() => {
+      result.current.calculateThePublishSpeedTestResult();
+    });
+    
+    expect(result.current.speedTestObject.message).toBe('Your connection quality is poor. You may experience interruptions');
+    expect(result.current.speedTestObject.isfinished).toBe(true);
+    expect(result.current.speedTestObject.progressValue).toBe(100);
+  });
+
+  it('handles negative values in stats calculations', () => {
+    const { result } = renderHook(() => useSpeedTest(defaultProps));
+    
+    act(() => {
+      result.current.startSpeedTest();
+    });
+    
+    // Prepare mock stats with negative values
+    result.current.statsList.current = [
+      {
+        videoRoundTripTime: '-1',
+        audioRoundTripTime: '-1',
+        videoPacketsLost: '-10',
+        totalVideoPacketsSent: '-100',
+        totalAudioPacketsSent: '-100',
+        audioPacketsLost: '-10',
+        videoJitter: '-1',
+        audioJitter: '-1',
+        currentOutgoingBitrate: '-1'
+      },
+      {
+        videoRoundTripTime: '-1',
+        audioRoundTripTime: '-1',
+        videoPacketsLost: '-10',
+        totalVideoPacketsSent: '-100',
+        totalAudioPacketsSent: '-100',
+        audioPacketsLost: '-10',
+        videoJitter: '-1',
+        audioJitter: '-1',
+        currentOutgoingBitrate: '-1'
+      },
+      {
+        videoRoundTripTime: '-1',
+        audioRoundTripTime: '-1',
+        videoPacketsLost: '-10',
+        totalVideoPacketsSent: '-100',
+        totalAudioPacketsSent: '-100',
+        audioPacketsLost: '-10',
+        videoJitter: '-1',
+        audioJitter: '-1',
+        currentOutgoingBitrate: '-1'
+      }
+    ];
+    
+    // Should not throw errors with negative values
+    act(() => {
+      result.current.calculateThePublishSpeedTestResult();
+    });
+    
+    // All negative values should be converted to 0
+    expect(result.current.speedTestObject.isfinished).toBe(true);
+  });
 }); 
\ No newline at end of file
diff --git a/react/src/hooks/useSpeedTest.js b/react/src/hooks/useSpeedTest.js
index cbe3d66e..95893449 100644
--- a/react/src/hooks/useSpeedTest.js
+++ b/react/src/hooks/useSpeedTest.js
@@ -43,7 +43,7 @@ export default function useSpeedTest(props) {
       
       // Set a timeout to handle stuck tests
       setTimeout(() => {
-        if (speedTestProgress < 40) {
+        if (speedTestProgress.current < 40) {
           // It means that it's stuck before publish started
           stopSpeedTest();
           setSpeedTestObjectFailed("Speed test failed. It may be due to firewall, wi-fi or network restrictions. Change your network or Try again");
@@ -466,11 +466,13 @@ export default function useSpeedTest(props) {
     setSpeedTestObject,
     setAndFillPlayStatsList,
     setAndFillPublishStatsList,
+    speedTestForPublishWebRtcAdaptorInfoCallback,
     speedTestCounter,
     statsList,
     calculateThePlaySpeedTestResult,
     processUpdatedStatsForPlaySpeedTest,
     setSpeedTestObjectFailed,
+    calculateThePublishSpeedTestResult,
     setSpeedTestObjectProgress,
   };
 } 
\ No newline at end of file