Fixed admin-x-settings tests failing because postData was not JSON

This commit is contained in:
Chris Raible 2024-08-29 23:35:46 -07:00
parent d959bdb914
commit 4dc2f2f267

View File

@ -186,7 +186,12 @@ export async function mockApi<Requests extends Record<string, MockRequestConfig>
});
}
const requestBody = JSON.parse(route.request().postData() || 'null');
let requestBody = null;
try {
requestBody = JSON.parse(route.request().postData() || 'null');
} catch {
requestBody = route.request().postData();
}
lastApiRequests[matchingMock.name] = {
body: requestBody,