Skip to content

Testing ​

bash
npm test            # server + client unit tests
npm test -w server  # server only
npm test -w client  # client only

Server unit tests ​

Vitest, in server/tests/. vitest.config.js sets a dummy environment so modules that read config can be imported without a database.

FileCovers
amount.test.jsStroop/kobo conversion, rejection of bad input, NGN rounding
crypto.test.jsEncryption round trip, unique IVs, wrong key, tampering
pagination.test.jsPage clamping and metadata
tradeRules.test.jsParty resolution, every action × role × status, deadlines, fallback status
validators.test.jsRegistration, orders, withdrawals, KYC age, payout accounts, phone normalisation
reputation.test.jsCompletion rate and stat folding
fileType.test.jsImage signature detection

Keep business rules in pure modules (like tradeRules.js) so they can be tested without Prisma or Horizon.

Client unit tests ​

client/src/lib/*.test.js — formatting and form helpers.

Smoke test ​

server/scripts/smoke-test.mjs exercises a running API against Stellar testnet and a disposable database:

  • registers two traders and funds them with Friendbot
  • adds a payout account and posts a sell order
  • opens a trade (real escrow lock), joins the socket room
  • sends a chat message with an image
  • marks paid, releases, and checks the buyer's on-chain balance increased by 100 XLM
  • cancels a second trade and checks the order reopened
  • forces a payment deadline into the past and waits for the scheduler's auto-refund
  • withdraws XLM and verifies an email link
bash
npm run dev:server   # in one terminal
API_URL=http://localhost:4000 npm run smoke -w server

DANGER

The smoke test writes directly to the database to skip email and KYC steps. It refuses to run with NODE_ENV=production or STELLAR_NETWORK=public.

CI ​

GitHub Actions validates the Prisma schema, generates the client, runs both test suites and builds the client on every push and pull request.

Nexlm is a peer-to-peer facilitator and never holds customer Naira.