Skip to content

jest config doesn't separate DB-requiring integration specs from unit specs — npm run test fails without a live Postgres, with no clear signal why #177

Description

@chonilius

package.json's jest config sets rootDir: "src" and testRegex: ".*\\.spec\\.ts$" with no testPathIgnorePatterns. src/database/escrow-fk-integrity.integration.spec.ts matches that same regex (it ends in .spec.ts) but, per its own doc comment, genuinely requires a live Postgres connection (synchronize: true against a real DataSource) — unlike every other .spec.ts file in the repo, which mocks its repositories.

In CI this is invisible because the "Run Unit & Integration Tests" step explicitly provides DATABASE_URL pointing at the workflow's postgres service container — so the step name already tacitly acknowledges two different test tiers are being run together. But a contributor running npm run test locally without DATABASE_URL set (e.g. before running docker compose up -d db, or simply not realizing one .spec.ts file among ~30 needs a database) gets a Postgres connection failure mixed into what looks like a fast, dependency-free unit test run, with no jest-level distinction between "this failed because of a real bug" and "this failed because you don't have a database running."

Consider a testPathIgnorePatterns (or a separate jest project/config) excluding *.integration.spec.ts from the default npm run test script, with its own npm run test:integration script that documents the DATABASE_URL requirement explicitly — mirroring how test:e2e already gets its own script and documented prerequisite in the README.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Stellar WaveIssues in the Stellar wave programarchitectureArchitecture/design issuedocumentationImprovements or additions to documentationtestingTesting/QA infrastructurevery hardVery difficult task, expert-level effort required

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions