diff --git a/README.md b/README.md index f0fd17a915..2410b5b11a 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,18 @@ yarn run lint ### Test +Disable API tests OR define all required explorer API keys. + +```bash +export DISABLE_API_TESTS=1 +# OR +export EXPLORER_API_KEY_MAINNET= +export EXPLORER_API_KEY_RINKEBY= +export EXPLORER_API_KEY_FUSE= +export EXPLORER_API_KEY_MATIC= +export EXPLORER_API_KEY_FANTOM= +``` + Test all the packages in the monorepo. ```bash diff --git a/packages/payment-detection/README.md b/packages/payment-detection/README.md index 60f039f3fe..63404465ef 100644 --- a/packages/payment-detection/README.md +++ b/packages/payment-detection/README.md @@ -64,3 +64,21 @@ The code generation is included in the pre-build script and can be run manually: ``` yarn codegen ``` + +# Test + +The ETH `InfoRetriever` tests require explorer API keys. Before running the +payment-detection tests, define `DISABLE_API_TESTS` or define all required +explorer API keys. + +```bash +export DISABLE_API_TESTS=1 +# OR +export EXPLORER_API_KEY_MAINNET= +export EXPLORER_API_KEY_RINKEBY= +export EXPLORER_API_KEY_FUSE= +export EXPLORER_API_KEY_MATIC= +export EXPLORER_API_KEY_FANTOM= + +yarn run test +``` diff --git a/packages/payment-detection/test/eth/info-retriever.test.ts b/packages/payment-detection/test/eth/info-retriever.test.ts index 635c5b4c09..c61fc98be8 100644 --- a/packages/payment-detection/test/eth/info-retriever.test.ts +++ b/packages/payment-detection/test/eth/info-retriever.test.ts @@ -45,7 +45,15 @@ describe('api/eth/info-retriever', () => { await expect(infoRetreiver.getTransferEvents()).rejects.toThrowError(); }); - describe('Multichain', () => { + // Utility for conditionally skipping tests + const describeIf = ( + condition: any, + ...args: [string | number | Function | jest.FunctionLike, jest.EmptyFunction] + ) => (condition ? describe(...args) : describe.skip(...args)); + + // Skip tests if build is from external fork or API tests are disabled + // External forks cannot access secret API keys + describeIf(!process.env.CIRCLE_PR_NUMBER && !process.env.DISABLE_API_TESTS, 'Multichain', () => { // TODO temporary disable xDAI, CELO, Sokol, and Goerli // FIXME: API-based checks should run nightly and be mocked for CI [