Skip to content

Conversation

@miantalha45
Copy link
Contributor

Summary

Adds the Phase 1 foundation for migrating FaaS integration tests from bash to Node/TypeScript, as discussed with the maintainer (fetch-only, manual stub approach, protocol reuse where applicable).

Changes

Helpers (test/integration/helpers.ts)

  • waitForReadiness(baseUrl, maxRetries?, intervalMs?) – Polls GET /readiness until 200; on connection failure throws a clear message to start the FaaS first.
  • getDeployments(baseUrl)GET /api/inspect, returns Deployment[] (protocol type).
  • getPrefix(baseUrl, suffix, maxRetries?, intervalMs?) – Resolves prefix for a deployment by suffix with retries.
  • callFunction(baseUrl, prefix, suffix, version, funcName, args)POST to .../call/{funcName} with JSON body; returns parsed response.

All HTTP is done with fetch (no axios). Types use @metacall/protocol (Deployment).

Smoke test (test/integration/readiness.spec.ts)

  • before() waits for FaaS readiness.
  • Two tests: readiness check passes; inspect returns an array.

Config and deps

  • Script: integration:ts – runs Mocha with ts-node on test/integration/**/*.spec.ts.
  • DevDependencies: chai, ts-node, @types/chai.
  • tsconfig: include extended with test/**/*.ts; lib includes DOM for global fetch typing.

How to run

  1. Start the FaaS (e.g. npm start in another terminal).
  2. Run: npm run integration:ts
    Optional: BASE_URL=http://localhost:9000 npm run integration:ts

The existing npm run integration (test.sh) is unchanged.

  • Next: Phase 2 – package deployment tests using these helpers.

- Add test/integration/helpers (waitForReadiness, getDeployments, getPrefix, callFunction) using fetch
- Add readiness.spec.ts smoke test (readiness + inspect)
- Add npm script integration:ts (Mocha + ts-node)
- Add chai, ts-node, @types/chai; extend tsconfig for test/**/*.ts and DOM lib for fetch types
- Keep existing integration (test.sh) unchanged
@viferga viferga marked this pull request as draft February 10, 2026 16:26
@viferga
Copy link
Member

viferga commented Feb 10, 2026

I am converting this to draft because the idea is to move the common code to metacall/protocol repository. Until this is more advanced, it is better if it remains as a draft.

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.

2 participants