diff --git a/packages/core/src/model/artifacts/HTTPRequestResponse.ts b/packages/core/src/model/artifacts/HTTPRequestResponse.ts index 987ec0f856a..58d2e2cc191 100644 --- a/packages/core/src/model/artifacts/HTTPRequestResponse.ts +++ b/packages/core/src/model/artifacts/HTTPRequestResponse.ts @@ -12,13 +12,15 @@ export interface RequestAndResponse extends JSONObject { request: { url: string; method: string; - headers: { [header: string]: string }; + headers: Record; data?: any; }; response: { status: number; data?: any; - headers?: { [header: string]: string }; + headers?: Record & { + 'set-cookie'?: string[] + }; }; } diff --git a/packages/rest/src/screenplay/abilities/CallAnApi.ts b/packages/rest/src/screenplay/abilities/CallAnApi.ts index 76d7e21d69d..82fc94c4004 100644 --- a/packages/rest/src/screenplay/abilities/CallAnApi.ts +++ b/packages/rest/src/screenplay/abilities/CallAnApi.ts @@ -1,5 +1,5 @@ import { Ability, ConfigurationError, LogicError, TestCompromisedError, UsesAbilities } from '@serenity-js/core'; -import axios, { AxiosError, AxiosInstance, AxiosPromise, AxiosRequestConfig, AxiosResponse } from 'axios'; +import axios, { AxiosDefaults, AxiosError, AxiosInstance, AxiosPromise, AxiosRequestConfig, AxiosResponse } from 'axios'; const mergeConfig = require('axios/lib/core/mergeConfig'); // eslint-disable-line @typescript-eslint/no-var-requires const buildFullPath = require('axios/lib/core/buildFullPath'); // eslint-disable-line @typescript-eslint/no-var-requires @@ -126,7 +126,7 @@ export class CallAnApi implements Ability { * * @see {@link AxiosRequestConfig} */ - modifyConfig(fn: (original: AxiosRequestConfig) => any): void { + modifyConfig(fn: (original: AxiosDefaults) => any): void { fn(this.axiosInstance.defaults); } diff --git a/packages/serenity-bdd/src/stage/crew/serenity-bdd-reporter/processors/transformations/activityRelatedArtifact.ts b/packages/serenity-bdd/src/stage/crew/serenity-bdd-reporter/processors/transformations/activityRelatedArtifact.ts index 4cd76292512..381b263f7be 100644 --- a/packages/serenity-bdd/src/stage/crew/serenity-bdd-reporter/processors/transformations/activityRelatedArtifact.ts +++ b/packages/serenity-bdd/src/stage/crew/serenity-bdd-reporter/processors/transformations/activityRelatedArtifact.ts @@ -60,7 +60,7 @@ export function activityRelatedArtifact report) } -function mapToString(dictionary: {[key: string]: string}) { +function mapToString(dictionary: Record) { return Object.keys(dictionary).map(key => `${key}: ${dictionary[key]}`).join('\n'); } @@ -88,9 +88,9 @@ function httpRequestResponse(activityI method: requestResponse.request.method.toUpperCase(), path: requestResponse.request.url, content: bodyToString(requestResponse.request.data), - contentType: requestResponse.request.headers['Content-Type'] || '', // todo: add a case insensitive proxy around this RFC 2616: 4.2 - requestHeaders: mapToString(requestResponse.request.headers) || '', - requestCookies: requestResponse.request.headers.Cookie || '', // todo: add a case insensitive proxy around this RFC 2616: 4.2 + contentType: String(requestResponse.request.headers['Content-Type'] || ''), // todo: add a case insensitive proxy around this RFC 2616: 4.2 + requestHeaders: mapToString(requestResponse.request.headers || {}) || '', + requestCookies: String(requestResponse.request.headers.Cookie || ''), // todo: add a case insensitive proxy around this RFC 2616: 4.2 statusCode: requestResponse.response.status, responseHeaders: mapToString(requestResponse.response.headers) || '', responseCookies: requestResponse.response.headers.Cookie || '', // todo: add a case insensitive proxy around this RFC 2616: 4.2