Skip to content

Commit ac17a2a

Browse files
committed
[tests] Add assertWarnDev, assertErrorDev, assertLogDev
1 parent 5c8c225 commit ac17a2a

File tree

3 files changed

+1693
-8
lines changed

3 files changed

+1693
-8
lines changed

packages/internal-test-utils/ReactInternalTestUtils.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ 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';
1520

1621
import {thrownErrors, actingUpdatesScopeDepth} from './internalAct';
@@ -317,6 +322,22 @@ ${diff(expectedLog, actualLog)}
317322
throw error;
318323
}
319324

325+
export const assertLogDev = createLogAssertion(
326+
'log',
327+
'assertLogDev',
328+
clearLogs,
329+
);
330+
export const assertWarnDev = createLogAssertion(
331+
'warn',
332+
'assertWarnDev',
333+
clearWarnings,
334+
);
335+
export const assertErrorDev = createLogAssertion(
336+
'error',
337+
'assertErrorDev',
338+
clearErrors,
339+
);
340+
320341
// Simulates dispatching events, waiting for microtasks in between.
321342
// This matches the browser behavior, which will flush microtasks
322343
// between each event handler. This will allow discrete events to

0 commit comments

Comments
 (0)