Skip to content

Commit 7c2419d

Browse files
committed
test: silence noisy warnings in frontend tests for clean output
1 parent 9460a5e commit 7c2419d

2 files changed

Lines changed: 29 additions & 5 deletions

File tree

.tmp/codeql/js-db/diagnostic/cli-diagnostics-add-20260221T201037.828Z.json renamed to .tmp/codeql/js-db/diagnostic/cli-diagnostics-add-20260221T201237.859Z.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"timestamp":"2026-02-21T21:10:37.828072+01:00","source":{"id":"cli/database/create","name":"CodeQL CLI: database create"},"plaintextMessage":"A fatal error occurred: No GitHub token was provided to auto-detect the repository's languages. Please either provide one or specify the languages manually using --language.\n(eventual cause: MissingTokenException \"An operation was attempted that requires a GitHub token but one could not be fou...\")","severity":"error","visibility":{"telemetry":false},"attributes":{"exitCode":2}}
1+
{"timestamp":"2026-02-21T21:12:37.859107+01:00","source":{"id":"cli/database/create","name":"CodeQL CLI: database create"},"plaintextMessage":"A fatal error occurred: No GitHub token was provided to auto-detect the repository's languages. Please either provide one or specify the languages manually using --language.\n(eventual cause: MissingTokenException \"An operation was attempted that requires a GitHub token but one could not be fou...\")","severity":"error","visibility":{"telemetry":false},"attributes":{"exitCode":2}}

frontend/src/App.test.js

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
1-
import { render } from '@testing-library/react';
2-
import App from './App';
1+
// Silence noisy warnings in tests - MUST happen before App load
2+
const originalWarn = console.warn;
3+
const originalError = console.error;
4+
5+
console.warn = (...args) => {
6+
if (
7+
(typeof args[0] === 'string' && args[0].includes('React Router Future Flag Warning')) ||
8+
(typeof args[0] === 'string' && args[0].includes('Warning: Importing directly from "services/authService" is deprecated'))
9+
) {
10+
return;
11+
}
12+
originalWarn(...args);
13+
};
14+
console.error = (...args) => {
15+
if (typeof args[0] === 'string' && args[0].includes('Warning: `ReactDOMTestUtils.act` is deprecated')) {
16+
return;
17+
}
18+
originalError(...args);
19+
};
20+
21+
import { render, act } from '@testing-library/react';
22+
23+
// Now require App
24+
const App = require('./App').default;
325

426
// Mock ESM-only modules
527
jest.mock('react-markdown', () => (props) => {
@@ -21,8 +43,10 @@ jest.mock('react-syntax-highlighter/dist/esm/styles/prism', () => ({
2143
vscDarkPlus: {},
2244
}));
2345

24-
test('renders learn react link', () => {
25-
render(<App />);
46+
test('renders learn react link', async () => {
47+
await act(async () => {
48+
render(<App />);
49+
});
2650
// This is a placeholder test. Depending on what App renders, this might need adjustment.
2751
// For now, let's just check if it renders without crashing.
2852
expect(true).toBe(true);

0 commit comments

Comments
 (0)