GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [tests] add `assertConsole<method>Dev` helpers (#28732) · react/react@608edcc

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages
    • internal-test-utils
      • ReactInternalTestUtils.js
      • __tests__
        • ReactInternalTestUtils-test.js
      • consoleMock.js
      • internalAct.js
    • jest-react/src
      • JestReact.js
  • scripts/jest/matchers
    • reactTestMatchers.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/internal-test-utils/ReactInternalTestUtils.js‎

Copy file name to clipboardExpand all lines: packages/internal-test-utils/ReactInternalTestUtils.js
+24-1Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,14 @@ import {diff} from 'jest-diff';
1010
import {equals} from '@jest/expect-utils';
1111
import enqueueTask from './enqueueTask';
1212
import simulateBrowserEventDispatch from './simulateBrowserEventDispatch';
13-
13+
import {
14+
clearLogs,
15+
clearWarnings,
16+
clearErrors,
17+
createLogAssertion,
18+
} from './consoleMock';
1419
export {act} from './internalAct';
20+
const {assertConsoleLogsCleared} = require('internal-test-utils/consoleMock');
1521

1622
import {thrownErrors, actingUpdatesScopeDepth} from './internalAct';
1723

@@ -24,6 +30,7 @@ function assertYieldsWereCleared(caller) {
2430
Error.captureStackTrace(error, caller);
2531
throw error;
2632
}
33+
assertConsoleLogsCleared();
2734
}
2835

2936
export async function waitForMicrotasks() {
@@ -317,6 +324,22 @@ ${diff(expectedLog, actualLog)}
317324
throw error;
318325
}
319326

327+
export const assertConsoleLogDev = createLogAssertion(
328+
'log',
329+
'assertConsoleLogDev',
330+
clearLogs,
331+
);
332+
export const assertConsoleWarnDev = createLogAssertion(
333+
'warn',
334+
'assertConsoleWarnDev',
335+
clearWarnings,
336+
);
337+
export const assertConsoleErrorDev = createLogAssertion(
338+
'error',
339+
'assertConsoleErrorDev',
340+
clearErrors,
341+
);
342+
320343
// Simulates dispatching events, waiting for microtasks in between.
321344
// This matches the browser behavior, which will flush microtasks
322345
// between each event handler. This will allow discrete events to

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.