19 lines
451 B
TypeScript
19 lines
451 B
TypeScript
import { APIResponse } from '@playwright/test';
|
|
import { ApiTestState } from './fixtures';
|
|
|
|
/**
|
|
* Stores a response and its parsed body/status into apiState.
|
|
*/
|
|
export async function storeResponse(
|
|
response: APIResponse,
|
|
apiState: ApiTestState
|
|
): Promise<void> {
|
|
apiState.lastResponse = response;
|
|
apiState.lastStatus = response.status();
|
|
try {
|
|
apiState.lastBody = await response.json();
|
|
} catch {
|
|
apiState.lastBody = null;
|
|
}
|
|
}
|