Skip to content

fix: integration tests, local FaaS, workdir, test harness, and type safety#188

Draft
miantalha45 wants to merge 1 commit intometacall:masterfrom
miantalha45:fix-deploy-tests
Draft

fix: integration tests, local FaaS, workdir, test harness, and type safety#188
miantalha45 wants to merge 1 commit intometacall:masterfrom
miantalha45:fix-deploy-tests

Conversation

@miantalha45
Copy link

Summary

Fixes failing deploy integration tests so all 22 tests pass when run with TEST_DEPLOY_LOCAL=true against a local FaaS.

Changes

CLI behavior

  • Require explicit --workdir (src/cli/args.ts): Removed default workdir = process.cwd(). Default projectName is set only when workdir is provided. Avoids accidentally deploying the current directory (e.g. the deploy repo).
  • Use dev URL when testing (src/index.ts): API base URL uses config.devURL when process.env.TEST_DEPLOY_LOCAL === 'true' or --dev is set, so the CLI talks to local FaaS in tests.
  • Persist dev token (src/startup.ts): In dev mode, the 'local' token is saved to config once so the CLI and test helpers (e.g. deployed(), deleted()) share the same auth.

Type safety / lint

  • apiError (src/cli/messages.ts): Typed err.response and safe handling of status/data so ESLint/TypeScript are satisfied and missing or non-string response data is handled safely.

Test harness (src/test/cli.ts)

  • Env for child process: runWithInput accepts an env argument; runCLI passes TEST_DEPLOY_LOCAL: 'true' when running locally so the spawned CLI uses local FaaS.
  • Stderr filtering: Added isRealError() so Node deprecation warnings on stderr do not fail tests; only CLI-style (X , ! , Error:) or HTTP-style errors are treated as failures.
  • Dev URL in helpers: deployed() and deleted() use config.devURL when TEST_DEPLOY_LOCAL === 'true'.

Integration spec (src/test/cli.integration.spec.ts)

  • stripAnsi: Helper to strip ANSI escape codes from captured stdout. All “Deploying” and “Deploy Delete Succeed” assertions use stripAnsi(result) so tests pass with chalk output.
  • addRepoSuffix: Derived from repo URL (e.g. examples for .../metacall/examples) to match how FaaS names deployments.
  • Delete message: Assertions expect exact 'i Deploy Delete Succeed\n' (aligned with FaaS response).

Other

  • package.json / package-lock.json: Newline at end of file (cosmetic).

Testing

  • TEST_DEPLOY_LOCAL=true npm test — all 22 deploy integration tests pass (6 login tests are skipped when running locally).

@viferga
Copy link
Member

viferga commented Feb 3, 2026

I am reviewing slowly the PR. I am not sure everything is correct, the first part I have done in relation to your PR is solving a known issue about execution paths:
metacall/faas@3a4816b

It broke the tests because I also changed the repositoryName function, the correct naming is like that. I am updating the tests: https://github.com/metacall/faas/actions/runs/21610629884/job/62278314670

I am putting this PR into draft meanwhile. We can talk about how to proceed but it would be better if we can focus on atomic parts and solve them as I did right now.

@viferga viferga marked this pull request as draft February 3, 2026 00:00
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