Skip to content

Commit

Permalink
fix(rest): updated Axios to 0.27.2
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-molak committed Jul 19, 2022
1 parent d3e9462 commit a5925c0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
6 changes: 4 additions & 2 deletions packages/core/src/model/artifacts/HTTPRequestResponse.ts
Expand Up @@ -12,13 +12,15 @@ export interface RequestAndResponse extends JSONObject {
request: {
url: string;
method: string;
headers: { [header: string]: string };
headers: Record<string, string | number | boolean>;
data?: any;
};
response: {
status: number;
data?: any;
headers?: { [header: string]: string };
headers?: Record<string, string> & {
'set-cookie'?: string[]
};
};
}

Expand Down
4 changes: 2 additions & 2 deletions 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

Expand Down Expand Up @@ -126,7 +126,7 @@ export class CallAnApi implements Ability {
*
* @see {@link AxiosRequestConfig}
*/
modifyConfig(fn: (original: AxiosRequestConfig) => any): void {
modifyConfig(fn: (original: AxiosDefaults<any>) => any): void {
fn(this.axiosInstance.defaults);
}

Expand Down
Expand Up @@ -60,7 +60,7 @@ export function activityRelatedArtifact<Context extends SerenityBDDReportContext
.else(_ => report)
}

function mapToString(dictionary: {[key: string]: string}) {
function mapToString(dictionary: Record<string, string | number | boolean>) {
return Object.keys(dictionary).map(key => `${key}: ${dictionary[key]}`).join('\n');
}

Expand Down Expand Up @@ -88,9 +88,9 @@ function httpRequestResponse<Context extends SerenityBDDReportContext>(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
Expand Down

0 comments on commit a5925c0

Please sign in to comment.