Test Client Overrides
Test Harness allows test authors to override various clients (AppClient, BotClient, UserClient) when running tests. Test Harness also allows test authors to provide implementations for the Slack API methods without a default implementation by the test harness. Negative testing of Slack APIs is allowed as well.
To mock the clients, the test author must extend from the proper client mock (AppClientMock, BotClientMock, UserClientMock). The tester then provides override implementations for the API methods to mock. The implementation must receive the request payload as the parameter and return a response payload as a result. You can override multiple methods in the same mock, but any methods that aren’t overridden default to the implementation that the test harness provides.
Methods with a default implementation:
If you provide a constructor implementation for your mock client, you must call the super method to insure access to the default api method implementations.
To use the mock implementation it must be set on the Slack State object by calling the proper method in the test.
It’s optional, but recommended, to clear the mock clients after the test finishes by calling the proper methods in the test.
Alternatively you can call SlackState.clearAllClientMocks() to clear them all at the same time.