You can also mock sendbird, here the code I used to mock sendbird chat and groupChannels :
/* eslint-disable object-shorthand */
/* eslint-disable @typescript-eslint/no-empty-function */
import '@testing-library/jest-dom/extend-expect';
const channels = [
{
members: [
{
userId: '9878f560-0499-4db1-89d8-782717e32d7f',
},
{
userId: '76bf72cc-0e5f-41a2-a209-b097a36d3bd5',
},
],
url: 'sendbird_group_channel_url1',
unreadMessageCount: 1,
lastMessage: {
createdAt: 1668000173366,
sender: {
userId: '76bf72cc-0e5f-41a2-a209-b097a36d3bd5',
nickname: 'Alex Chat',
},
message: 'Hey!',
},
},
{
members: [
{
userId: '9878f560-0499-4db1-89d8-782717e32d7f',
},
{
userId: '76bf72cc-0e5f-41a2-a209-b097a36d3bd5',
},
],
url: 'sendbird_group_channel_url2',
unreadMessageCount: 1,
lastMessage: {
createdAt: 1668000173366,
sender: {
userId: '76bf72cc-0e5f-41a2-a209-b097a36d3bd5',
nickname: 'Alex Chat',
},
message: 'Message!',
},
},
];
jest.mock('@sendbird/chat', () => {
return {
__esModule: true,
default: {
init: (p: any) => {
return {
addUserEventHandler: (p: any, p2: any) => {},
setSessionHandler: (p: any) => {},
removeUserEventHandler: (p: any) => {},
connect: (p: any, a: any) => {},
groupChannel: {
addGroupChannelHandler: (p: any, p2: any) => {},
removeGroupChannelHandler: (p: any) => {},
getTotalUnreadMessageCount: () => 2,
createMyGroupChannelListQuery: (p: any) => ({
hasNext: true,
next: () => channels,
}),
},
};
},
},
SessionHandler: jest.fn().mockImplementation(() => {
return {};
}),
UserEventHandler: jest.fn().mockImplementation(() => {
return {};
}),
};
});
jest.mock('@sendbird/chat/groupChannel', () => {
return {
__esModule: true,
GroupChannel: {},
GroupChannelCreateParams: {},
GroupChannelHandler: jest.fn().mockImplementation(() => {
return {};
}),
GroupChannelListOrder: {},
GroupChannelListQuery: {},
GroupChannelListQueryParams: {},
GroupChannelModule: jest.fn().mockImplementation(() => {
return {};
}),
MyMemberStateFilter: {},
SendbirdGroupChat: {},
GroupChannelHideParams: {},
};
});
jest.mock('@sendbird/chat/message', () => {
return {
__esModule: true,
BaseMessage: {},
FileMessage: {},
MessageModule: jest.fn().mockImplementation(() => {
return {};
}),
MessageTypeFilter: {},
ReplyType: {},
};
});
It returns 2 fake Group Channels bu you can also return fake messages using this logic