The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/apps/meteor/tests/e2e/utils/parseMeteorResponse.ts

18 lines
475 B

import type { APIResponse } from '@playwright/test';
import type { Serialized } from '@rocket.chat/core-typings';
export const parseMeteorResponse = async <ResponseType = unknown>(response: APIResponse): Promise<Serialized<ResponseType>> => {
const { message, success } = await response.json();
if (!success) {
throw new Error(message);
}
const { result, error } = JSON.parse(message);
if (error) {
throw new Error(JSON.stringify(error));
}
return result;
};