Run pnpm test
to run unit tests locally. These tests are run automatically on every pull request.
To run end-to-end tests, run pnpm test:e2e
in terminal. To run tests with Chrome only, run pnpm test:e2e:chrome
.
Make sure you run pnpm build chrome
before running tests.
Before you begin, you need to setup some environment variables/secrets in tests/e2e/.env
.
- Copy
tests/e2e/.env.example
totests/e2e/.env
- Update
tests/e2e/.env
with your secrets.
Environment variables for test are defined in env.d.ts
as TestEnvVars
.
To get the TEST_WALLET_KEY_ID
, TEST_WALLET_PRIVATE_KEY
and TEST_WALLET_PUBLIC_KEY
vars, follow these steps:
- Load the extension in browser (via
chrome://extensions/
)- Once the extension is loaded, it'll generate a key-pair that we will need to connect with our wallet.
- Inspect service worker with "Inspect views service worker"
- Run following in devtools console to copy keys to your clipboard, and paste it in
tests/e2e/.env
:// 1. Gets generated keys from extension storage. // 2. Converts result to `TEST_WALLET_{X}="VAL"` format for use in .env file. // 3. Copies result to clipboard. copy( Object.entries( await chrome.storage.local.get(['privateKey', 'publicKey', 'keyId']), ) .map( ([k, v]) => `TEST_WALLET_${k.replace(/([A-Z])/g, '_$1').toUpperCase()}="${v}"`, ) .join('\n'), );
- Then copy
TEST_WALLET_PUBLIC_KEY
key to https://wallet.interledger-test.dev/settings/developer-keys under your wallet address. - Now you're ready to run the tests.
As these tests are expensive/time-consuming, these need to be triggered manually when needed, instead of on every pull request/commit.
For a pull request, users with write access to repository can trigger the workflow to run end-to-end tests by adding a review-comment (from PR Files tab) with body test-e2e
(exactly).
End-to-end tests run automatically daily before creating the Nightly release. You can also trigger that workflow manually from Actions Dashboard.