Skip to content

Commit 2a2e279

Browse files
motiz88facebook-github-bot
authored andcommitted
Reduce log spam from naggy mocks in tests (#54047)
Summary: TSIA Changelog: [Internal] Differential Revision: D83825727
1 parent 88cf30a commit 2a2e279

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

packages/react-native/ReactCommon/jsinspector-modern/tests/InspectorMocks.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ class MockInspectorPackagerConnectionDelegate
9797
executor_.add(callback);
9898
}
9999
}));
100+
EXPECT_CALL(*this, scheduleCallback(_, _)).Times(AnyNumber());
100101
}
101102

102103
// InspectorPackagerConnectionDelegate methods
@@ -168,6 +169,15 @@ class MockRuntimeTargetDelegate : public RuntimeTargetDelegate {
168169
collectSamplingProfile,
169170
(),
170171
(override));
172+
173+
inline MockRuntimeTargetDelegate() {
174+
using namespace testing;
175+
176+
// Silence "uninteresting mock function call" warnings for methods that
177+
// don't have side effects.
178+
179+
EXPECT_CALL(*this, supportsConsole()).Times(AnyNumber());
180+
}
171181
};
172182

173183
class MockRuntimeAgentDelegate : public RuntimeAgentDelegate {

packages/react-native/ReactCommon/jsinspector-modern/tests/InspectorPackagerConnectionTest.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ class InspectorPackagerConnectionTestBase : public testing::Test {
4949
socket->getDelegate().didOpen();
5050
return std::move(socket);
5151
});
52+
EXPECT_CALL(*packagerConnectionDelegate(), connectWebSocket(_, _))
53+
.Times(AnyNumber());
5254
}
5355

5456
void TearDown() override {

packages/react-native/ReactCommon/jsinspector-modern/tests/ReactInstanceIntegrationTest.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class ReactInstanceIntegrationTest
5050
std::shared_ptr<MockMessageQueueThread> messageQueueThread;
5151
std::shared_ptr<ErrorUtils> errorHandler;
5252

53-
MockRemoteConnection& getRemoteConnection() {
53+
NiceMock<MockRemoteConnection>& getRemoteConnection() {
5454
EXPECT_EQ(mockRemoteConnections_.objectsVended(), 1);
5555
auto rawPtr = mockRemoteConnections_[0];
5656
assert(rawPtr);
@@ -64,7 +64,7 @@ class ReactInstanceIntegrationTest
6464
size_t id_ = 1;
6565
bool verbose_ = false;
6666
std::optional<int> pageId_;
67-
UniquePtrFactory<MockRemoteConnection> mockRemoteConnections_;
67+
UniquePtrFactory<NiceMock<MockRemoteConnection>> mockRemoteConnections_;
6868
std::unique_ptr<ILocalConnection> clientToVM_;
6969
folly::QueuedImmediateExecutor immediateExecutor_;
7070
MockHostTargetDelegate hostTargetDelegate_;

0 commit comments

Comments
 (0)