From cc0286044db3cf5319cb74ff9e23c5f6da157b93 Mon Sep 17 00:00:00 2001 From: Oscar Reyes Date: Thu, 7 Mar 2024 14:34:30 -0600 Subject: [PATCH] chore: adding url parsing for tracetest.ts serverless tests --- serverless/tracetest.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/serverless/tracetest.ts b/serverless/tracetest.ts index 695fc43..c30f331 100644 --- a/serverless/tracetest.ts +++ b/serverless/tracetest.ts @@ -1,3 +1,4 @@ +import { URL } from 'url'; import Tracetest from '@tracetest/client'; import { TestResource } from '@tracetest/client/dist/modules/openapi-client'; import { config } from 'dotenv'; @@ -5,7 +6,18 @@ import { config } from 'dotenv'; config(); const { TRACETEST_API_TOKEN = '' } = process.env; -const [url = ''] = process.argv.slice(2); +const [raw = ''] = process.argv.slice(2); + +let url = ''; + +try { + url = new URL(raw).origin; +} catch (error) { + console.error( + 'The API Gateway URL is required as an argument. i.e: `npm test https://75yj353nn7.execute-api.us-east-1.amazonaws.com`' + ); + process.exit(1); +} const definition: TestResource = { type: 'Test',