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 5c8c225 commit ac17a2a
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 assertLogDev = createLogAssertion(
'log',
'assertLogDev',
clearLogs,
);
export const assertWarnDev = createLogAssertion(
'warn',
'assertWarnDev',
clearWarnings,
);
export const assertErrorDev = createLogAssertion(
'error',
'assertErrorDev',
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 ac17a2a

Please sign in to comment.