Skip to content

tests/ is not typechecked — tsconfig include is src/**/* only #170

Description

@Miracle656

Problem

tsconfig.json has:

"include": ["src/**/*"]

So tests/ — including the whole tests/integration/ suite — is never typechecked. npm run build and tsc --noEmit can both be clean while integration tests are broken at the type level.

How it surfaced

In #159 (PR #169) the IndexerState primary key changed from a singleton id to network. tsc --noEmit reported 0 errors and all 270 unit tests passed, while six integration suites failed at setup:

PrismaClientValidationError
FAIL tests/integration/api.test.ts
FAIL tests/integration/e2e.test.ts
FAIL tests/integration/migrations.test.ts
FAIL tests/integration/reorg-rollover.test.ts
FAIL tests/integration/reorg.test.ts
FAIL tests/integration/ws.test.ts

Cause: three call sites still used the removed key.

prisma.indexerState.create({ data: { id: 1, lastIndexedLedger: 101 } })
prisma.indexerState.findUnique({ where: { id: 1 } })

A typecheck covering tests/ would have caught all three instantly. Instead they were only found by running the integration job — which needs Postgres and a live API, so it does not run locally for most contributors.

This is a schema-change trap specifically: any future Prisma model change has the same blind spot.

Why the one-line fix does not work

Adding tests/**/* to include fails, because compilerOptions.rootDir is "src":

error TS6059: File 'tests/integration/api.test.ts' is not under rootDir 'src'.

rootDir controls the dist/ layout, so it cannot simply be widened without changing build output.

Suggested approach

Add a separate typecheck-only config that does not participate in the build:

// tsconfig.test.json
{
  "extends": "./tsconfig.json",
  "compilerOptions": {
    "rootDir": ".",
    "noEmit": true
  },
  "include": ["src/**/*", "tests/**/*"]
}

then wire it into CI, e.g. "typecheck": "tsc --noEmit -p tsconfig.test.json", run alongside the existing build.

Expect some pre-existing errors in tests/ on the first run — those should be fixed (or narrowly suppressed with a comment) as part of this, otherwise the new check lands red and gets ignored.

Acceptance criteria

  • tests/**/* is typechecked by some config
  • The build output in dist/ is unchanged (no test files emitted)
  • CI runs the test typecheck and it is green
  • Reverting the { id: 1 }{ network: 'testnet' } fix in tests/integration/setup.ts makes the new check fail (confirms it actually catches this class)

Drips Wave · Complexity: Easy · 100 points

Required: Before submitting, join the contributor Telegram so your work can be tracked and counted toward the Stellar Wave: https://t.me/+fxHXq8f1SwlkZDBk

Metadata

Metadata

Assignees

No one assigned

    Labels

    Stellar WaveIssues in the Stellar wave program

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions