From 2912357ec2167ef50469f0b287d562051e20a870 Mon Sep 17 00:00:00 2001 From: "lightwalker.eth" <126201998+lightwalker-eth@users.noreply.github.com> Date: Wed, 28 Aug 2024 03:27:47 +0300 Subject: [PATCH] Improve env var handling for nameguard-js (#382) * Improve env var handling for nameguard-js --- .changeset/large-pumas-call.md | 5 +++++ .github/workflows/typescript-packages-unit-tests.yml | 4 ++++ packages/nameguard-js/src/nameguard-js.test.ts | 12 ++++++++++++ 3 files changed, 21 insertions(+) create mode 100644 .changeset/large-pumas-call.md diff --git a/.changeset/large-pumas-call.md b/.changeset/large-pumas-call.md new file mode 100644 index 000000000..993e037cb --- /dev/null +++ b/.changeset/large-pumas-call.md @@ -0,0 +1,5 @@ +--- +"@namehash/nameguard-js": patch +--- + +Refine nameguard-js unit tests diff --git a/.github/workflows/typescript-packages-unit-tests.yml b/.github/workflows/typescript-packages-unit-tests.yml index 5c8fb8e55..c66ab490d 100644 --- a/.github/workflows/typescript-packages-unit-tests.yml +++ b/.github/workflows/typescript-packages-unit-tests.yml @@ -12,6 +12,10 @@ on: paths: - "packages/**" +env: + PROVIDER_URI_MAINNET: ${{ secrets.PROVIDER_URI_MAINNET }} + PROVIDER_URI_SEPOLIA: ${{ secrets.PROVIDER_URI_SEPOLIA }} + jobs: test: strategy: diff --git a/packages/nameguard-js/src/nameguard-js.test.ts b/packages/nameguard-js/src/nameguard-js.test.ts index 5335408d0..4becba75b 100644 --- a/packages/nameguard-js/src/nameguard-js.test.ts +++ b/packages/nameguard-js/src/nameguard-js.test.ts @@ -6,6 +6,18 @@ import { createClient } from "./nameguard-js"; const PROVIDER_URI_MAINNET = process.env.PROVIDER_URI_MAINNET; const PROVIDER_URI_SEPOLIA = process.env.PROVIDER_URI_SEPOLIA; +if (!PROVIDER_URI_MAINNET) { + throw new Error( + "The PROVIDER_URI_MAINNET environment variable is not defined.", + ); +} + +if (!PROVIDER_URI_SEPOLIA) { + throw new Error( + "The PROVIDER_URI_SEPOLIA environment variable is not defined.", + ); +} + /** * This is a fake endpoint that will not work. * If a client created with this endpoint tries to make an API request, it will throw an error.