Skip to content

Commit 237e9d2

Browse files
committed
factor tests to assert different behavior between prod and dev
1 parent ebce981 commit 237e9d2

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

packages/react-dom/src/__tests__/ReactDOMFizzSuppressHydrationWarning-test.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -866,17 +866,21 @@ describe('ReactDOMFizzServerHydrationWarning', () => {
866866
);
867867

868868
expect(Scheduler).toFlushAndYield([]);
869-
expect(mockError.mock.calls.length).toBe(1);
870-
expect(mockError.mock.calls[0]).toEqual([
871-
'Warning: Text content did not match. Server: "%s" Client: "%s"%s',
872-
'initial',
873-
'replaced',
874-
'\n' +
875-
' in h2 (at **)\n' +
876-
' in Suspense (at **)\n' +
877-
' in div (at **)\n' +
878-
' in App (at **)',
879-
]);
869+
if (__DEV__) {
870+
expect(mockError.mock.calls.length).toBe(1);
871+
expect(mockError.mock.calls[0]).toEqual([
872+
'Warning: Text content did not match. Server: "%s" Client: "%s"%s',
873+
'initial',
874+
'replaced',
875+
'\n' +
876+
' in h2 (at **)\n' +
877+
' in Suspense (at **)\n' +
878+
' in div (at **)\n' +
879+
' in App (at **)',
880+
]);
881+
} else {
882+
expect(mockError.mock.calls.length).toBe(0);
883+
}
880884
} finally {
881885
console.error = originalConsoleError;
882886
}

0 commit comments

Comments
 (0)