Skip to content

Make npm test run the TypeScript suite with Vitest - #134

Merged
memplethee-lab merged 6 commits into
LintError:mainfrom
DevMuhdishaq:feature/vitest-test-setup
Oct 12, 2026
Merged

memplethee-lab merged 6 commits into
LintError:mainfrom
DevMuhdishaq:feature/vitest-test-setup

Conversation

@DevMuhdishaq

@DevMuhdishaq DevMuhdishaq commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Make npm test actually run the TypeScript suite (Vitest)

Summary

Fixes #18. package.json ran node --test src/**/*.test.ts, which could never work:

  • Node 18/20 have no TypeScript loader, so node --test cannot execute .ts files.
  • The src/**/*.test.ts glob depended on shell expansion, so it behaved differently (or broke) on Windows/CI shells.
  • The test file used imports that Node's resolver rejected.

CI's test job only ran npm run build, so the suite never executed and regressions went unnoticed.

Changes

  • package.json - add vitest; test now runs vitest run, plus a test:watch script.
  • package-lock.json - regenerated so npm ci stays in sync (additive: 83 packages added, none changed or removed).
  • vitest.config.ts (new) - node environment, src/**/*.test.ts include, and the @/* -> ./* alias mirrored from tsconfig.json.
  • src/utils/stellar.test.ts - import test/describe/beforeEach/afterEach from vitest (assertions stay on node:assert), and import the unit under test via @/src/utils/stellar to prove alias resolution.
  • .github/workflows/ci.yml - the test job now runs npm test instead of just building.
  • CONTRIBUTING.md - document how to run the suite.

Acceptance criteria

  • npm test runs the existing stellar tests (via Vitest)
  • The CI test job executes the suite
  • The @/src/... path alias resolves in tests (exercised by the import in stellar.test.ts)

Notes

  • The lockfile is included and npm ci --dry-run resolves cleanly. No production code changed.

Closes #18

package.json ran "node --test src/**/*.test.ts", which cannot work: Node
20 has no TypeScript loader, the glob relies on shell expansion (so it
behaves differently on Windows/CI shells), and the test file's imports
use extensions/aliases Node's resolver rejects.

- Add vitest as a dev dependency
- "npm test" now runs "vitest run" (and "test:watch" for local dev)
- Add vitest.config.ts, including the "@/*" alias from tsconfig.json so
  tests resolve modules the same way the app does

Refs LintError#18
- Import test/describe/beforeEach/afterEach from "vitest" instead of
  "node:test"; node:assert assertions are unchanged and still work
- Import the unit under test via "@/src/utils/stellar" to exercise the
  path alias resolution required by the issue

Refs LintError#18
The test job ran "npm run build", which builds the app but never executes
a single test, so coverage and correctness could regress silently. Run
"npm test" instead so CI fails when the suite fails.

Closes LintError#18
Add a Testing section to CONTRIBUTING.md covering "npm test",
"npm run test:watch" and the "@/" alias used by tests.

Refs LintError#18
"npm ci" failed in CI because package.json declared vitest but the lock
file had no entry for it. Regenerated with
"npm install --package-lock-only".

The change is additive: 83 packages added, none changed or removed.

Refs LintError#18
The sendXLM "submits the signed transaction" test assumed
payment.destination.accountId() and payment.amount === '2.5'. With
@stellar/stellar-sdk 12.x the operation destination is the plain
G-address string and amount is normalized to 7 decimals ("2.5000000"),
so both assertions failed now that "npm test" actually runs.

Accept either the string or an Account for destination, and compare the
amount numerically.

Refs LintError#18
@memplethee-lab
memplethee-lab merged commit 38a7443 into LintError:main Oct 12, 2026
3 checks passed
guptakumarranjeet150 pushed a commit to guptakumarranjeet150/orionpay-UI that referenced this pull request Nov 10, 2026
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.

npm test script 'node --test src/**/*.test.ts' cannot run TypeScript tests

2 participants