Skip to content

Commit

Permalink
feat: enhanced FetcherStubError with non-matching request
Browse files Browse the repository at this point in the history
  • Loading branch information
sr1ch1 committed Feb 15, 2023
1 parent e794a1f commit e728f00
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sr1ch1/apollo-fetcher-stub",
"version": "1.1.0",
"version": "1.2.0",
"description": "A stub version of the apollo fetcher to be used for integration testing.",
"types": "./lib/cjs/types/index.d.ts",
"main": "./lib/cjs/index.js",
Expand Down
4 changes: 2 additions & 2 deletions src/fetcher-stub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {StubHeaderData} from "./stub-header-data";
import buildRequestMatcher, {createExactMatcher} from "./build-request-matcher";

export class FetcherStubError extends Error {
constructor(msg: string, public requestMatcher: string[]) {
constructor(msg: string, public request: string, public requestMatcher: string[]) {
super(msg);
Object.setPrototypeOf(this, FetcherStubError.prototype);
}
Expand Down Expand Up @@ -53,7 +53,7 @@ export class FetcherStub {
if (response) {
return Promise.resolve(response)
}
throw new FetcherStubError('Stub not prepared properly', this._resolver.getMatchingRequests());
throw new FetcherStubError('Stub not prepared properly', request, this._resolver.getMatchingRequests());
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/simpleFetcherResponse.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('SimpleFetcherResponse', () => {

// test ctor for good measure.
expect(new SimpleFetcherResponse()).not.toBeNull();
expect(new FetcherStubError('error', [])).not.toBeNull();
expect(new FetcherStubError('error', 'http://localhost',[])).not.toBeNull();
expect(await response.text()).toBe(bodyText);
});

Expand Down Expand Up @@ -55,4 +55,4 @@ describe('SimpleFetcherResponse', () => {

expect(await response.text()).toBe(await clonedResponse.text());
});
})
})

0 comments on commit e728f00

Please sign in to comment.