Skip to content

Commit

Permalink
[tests] Add assertWarnDev, assertErrorDev, assertLogDev
Browse files Browse the repository at this point in the history
  • Loading branch information
rickhanlonii committed Apr 3, 2024
1 parent dc984af commit 734b70c
Show file tree
Hide file tree
Showing 3 changed files with 1,693 additions and 8 deletions.
23 changes: 22 additions & 1 deletion packages/internal-test-utils/ReactInternalTestUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ import {diff} from 'jest-diff';
import {equals} from '@jest/expect-utils';
import enqueueTask from './enqueueTask';
import simulateBrowserEventDispatch from './simulateBrowserEventDispatch';

import {
clearLogs,
clearWarnings,
clearErrors,
createLogAssertion,
} from './consoleMock';
export {act} from './internalAct';

import {thrownErrors, actingUpdatesScopeDepth} from './internalAct';
Expand Down Expand Up @@ -317,6 +322,22 @@ ${diff(expectedLog, actualLog)}
throw error;
}

export const assertConsoleLogDev = createLogAssertion(
'log',
'assertConsoleLogDev',
clearLogs,
);
export const assertConsoleWarnDev = createLogAssertion(
'warn',
'assertConsoleWarnDev',
clearWarnings,
);
export const assertConsoleErrorDev = createLogAssertion(
'error',
'assertConsoleErrorDev',
clearErrors,
);

// Simulates dispatching events, waiting for microtasks in between.
// This matches the browser behavior, which will flush microtasks
// between each event handler. This will allow discrete events to
Expand Down
Loading

0 comments on commit 734b70c

Please sign in to comment.