Skip to content

ci: provision .env before running tests#62

Merged
islandbitcoin merged 1 commit into
mainfrom
fix/ci-provision-env-for-tests
Jul 8, 2026
Merged

ci: provision .env before running tests#62
islandbitcoin merged 1 commit into
mainfrom
fix/ci-provision-env-for-tests

Conversation

@islandbitcoin

Copy link
Copy Markdown
Contributor

Problem

The test CI job has been failing on main (and thus on every open PR, including #61) with:

SyntaxError: "REWARDS_ENABLED" is not defined in .env
SyntaxError: "BTC_PAY_SERVER" is not defined in .env

Root cause

babel.config.js uses the dotenv-import plugin (moduleName: '@env', path: '.env'), which validates every @env import against .env at transform time. .env is gitignored (.gitignore:77) and ci.yml never created one, so when yarn test runs jest → babel, the transform throws on the first @env import (e.g. src/utils/featureFlags.ts).

Lint and typecheck pass because they don't run the babel dotenv transform — only jest does, which is why test was the sole red check.

Fix

Copy .env.example.env before the test step. Verified .env.example already defines all 6 @env vars used across src/ (BTC_PAY_SERVER, FLASH_GRAPHQL_URI, FLASH_GRAPHQL_WS_URI, FLASH_LN_ADDRESS, FLASH_LN_ADDRESS_URL, REWARDS_ENABLED), so a single copy fully satisfies the plugin.

Independent of any feature work — this unblocks the test check for all open PRs.

🤖 Generated with Claude Code

The `test` job fails at babel-transform time with
`SyntaxError: "REWARDS_ENABLED" is not defined in .env` (and BTC_PAY_SERVER).
The dotenv-import babel plugin (moduleName '@env', path '.env') validates
every `@env` import against .env at transform time; .env is gitignored and
CI never created one, so jest's transform throws. Lint/typecheck pass
because they don't run that transform.

Copy .env.example (which already defines all 6 @env vars used in src/) to
.env before the test step. Pre-existing main failure; unblocks all PRs.
@islandbitcoin islandbitcoin merged commit 32a9a6b into main Jul 8, 2026
1 of 2 checks passed
islandbitcoin added a commit that referenced this pull request Jul 8, 2026
App.test.tsx fails to run in CI with "WebSocket implementation missing":
it imports App -> src/graphql/ApolloClient.ts, which eagerly calls
graphql-ws createClient at module load, requiring a WebSocket impl. CI
pins Node 20 (no global WebSocket); Node 22+ provides it, which masks the
issue in local dev. `ws` is already a dependency, so alias it onto
global.WebSocket in jest.setup.js.

Verified under Node 20: full suite 18/18 suites, 142 tests pass.
Second half of the CI test fix (follows the .env provisioning in #62).

Co-authored-by: Dread <dread@example.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant