Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

test(infra-monitoring): fix flaky test (#11021)

Vinicius Lourençoaddb234c8c60
diff --git a/frontend/src/container/InfraMonitoringK8s/Base/__tests__/K8sBaseList.test.tsx b/frontend/src/container/InfraMonitoringK8s/Base/__tests__/K8sBaseList.test.tsx
index 87fa04c958..4a6f1b52b8 100644
--- a/frontend/src/container/InfraMonitoringK8s/Base/__tests__/K8sBaseList.test.tsx
+++ b/frontend/src/container/InfraMonitoringK8s/Base/__tests__/K8sBaseList.test.tsx
@@ -37,6 +37,10 @@ jest.mock('utils/navigation', () => ({
const openInNewTabMock = openInNewTab as jest.Mock;
+// Mock Date.now to prevent flaky tests due to time-dependent values
+const MOCK_NOW = 1700000000000; // Fixed timestamp
+jest.spyOn(Date, 'now').mockReturnValue(MOCK_NOW);
+
// Mock DrawerWrapper to avoid CSS issues with jsdom
// SyntaxError: 'div#radix-:rbv,,._dialog__content_qf8bf_22 :focus' is not a valid selector
jest.mock('@signozhq/ui', () => ({
@@ -188,6 +192,7 @@ describe('K8sBaseList', () => {
await waitFor(() => {
const selectedItem = onUrlUpdateMock.mock.calls
.map((call) => call[0].searchParams.get('selectedItem'))
+ .filter(Boolean)
.pop();
expect(selectedItem).toBe(`PodId:${itemId}`);
});