diff --git a/README.md b/README.md index f00f6c4..47a3ccb 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,7 @@ const request = { /* https://api.dev.testing-farm.io/redoc#operation/request_a_n const response: NewRequestResponse = await api.newRequest(request); const response: unknown = await api.newRequest(request, false); +const response: unknown = await api.unsafeNewRequest(request /* unknown type */); ``` ### Test Request Details diff --git a/src/index.ts b/src/index.ts index 5531b97..c9eb4b9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -78,6 +78,10 @@ export default class TestingFarmAPI { ); } + async unsafeNewRequest(request: unknown): Promise { + return await this.link.post('requests', request); + } + async requestDetails(requestId: string): Promise; async requestDetails(requestId: string, strict: boolean): Promise; async requestDetails(requestId: string, strict?: boolean): Promise { diff --git a/test/integration/new-request.test.ts b/test/integration/new-request.test.ts index 570e933..44f91da 100644 --- a/test/integration/new-request.test.ts +++ b/test/integration/new-request.test.ts @@ -22,4 +22,21 @@ describe('Test Testing Farm POST /requests', () => { `[Error: {"message":"Test section is empty or test type is wrong."}]` ); }); + test('unsafe request', async () => { + const api = new TestingFarmAPI('https://api.dev.testing-farm.io/v0.1'); + + const response = api.unsafeNewRequest({ + api_key: 'api_key', + test: {}, + environments: [ + { + hardware: '{"something":"foobar"}', + }, + ], + }); + + await expect(response).rejects.toThrowErrorMatchingInlineSnapshot( + `[Error: {"message":"Test section is empty or test type is wrong."}]` + ); + }); });