Skip to content
Permalink
Browse files
fix(rest): Providing an invalid Axios configuration results in a Conf…
…igurationError instead of Logic
  • Loading branch information
jan-molak committed Feb 19, 2019
1 parent 672854e commit ba9c3db17e5625608597623ff56eb55881515b39
Showing with 5 additions and 5 deletions.
  1. +3 −3 packages/rest/spec/screenplay/abilities/CallAnApi.spec.ts
  2. +2 −2 packages/rest/src/screenplay/abilities/CallAnApi.ts
@@ -1,6 +1,6 @@
import 'mocha';

import { LogicError, TestCompromisedError } from '@serenity-js/core';
import { ConfigurationError, LogicError, TestCompromisedError } from '@serenity-js/core';
import axios from 'axios';
import MockAdapter from 'axios-mock-adapter';
import { given } from 'mocha-testdata';
@@ -114,8 +114,8 @@ describe('CallAnApi', () => {
callAnApi = CallAnApi.using(axiosInstance);

return expect(callAnApi.request({ method: 'get', url: '/some/api' })).to.be.rejectedWith('Looks like there was an issue with Axios configuration')
.then((error: LogicError) => {
expect(error).to.be.instanceOf(LogicError);
.then((error: ConfigurationError) => {
expect(error).to.be.instanceOf(ConfigurationError);
expect(error.stack).to.contain('Caused by: TypeError');
});
});
@@ -1,4 +1,4 @@
import { Ability, LogicError, TestCompromisedError, UsesAbilities } from '@serenity-js/core';
import { Ability, ConfigurationError, LogicError, TestCompromisedError, UsesAbilities } from '@serenity-js/core';
import axios, { AxiosError, AxiosInstance, AxiosPromise, AxiosRequestConfig, AxiosResponse } from 'axios';

/**
@@ -165,7 +165,7 @@ export class CallAnApi implements Ability {
case /Network Error/.test(rejected.message):
throw new TestCompromisedError(`A network error has occurred`, rejected);
case rejected instanceof TypeError:
throw new LogicError(`Looks like there was an issue with Axios configuration`, rejected);
throw new ConfigurationError(`Looks like there was an issue with Axios configuration`, rejected);
case ! (rejected as AxiosError).response:
throw new TestCompromisedError(`The API call has failed`, rejected);
default:

0 comments on commit ba9c3db

Please sign in to comment.