Skip to content

Conversation

@XxSURYANSHxX
Copy link

CI Pipeline Fixes: Backend Tests

Hey @pradeeban @karthiksathishjeemain So our GitHub Actions checks were failing for both the JS and Python backends, and I dug deep into it. The issue was that our tests were trying to hit a running server (like localhost:3000), but in GitHub Actions, there is no server running in the background.

I’ve refactored the tests to run "in-process" so they don't need a separate server. Here’s exactly what I did:

JavaScript Backend Changes

  1. Refactored server.js: I changed it slightly to export the app instance. This lets us import the app in our tests. I also added a check if (require.main === module) so it only starts listening on a port when we run node server.js, but not when we import it for testing.

  2. Updated api.test.js:

    • Switched from hitting http://localhost:3001 to using supertest.
    • supertest takes our Express app and simulates requests directly, which is the standard way to test Express apps in CI.
  3. Fixed package.json: The CI workflow was trying to run npm run lint, but we didn't have a lint script, so I removed that step from the workflow to verify the tests first.

Python Backend Changes

  1. Added httpx Dependency: Needed for the new testing tool.
  2. Refactored test_api.py:
    • Switched from requests to fastapi.testclient.TestClient.
    • This does the same thing as supertest but for Python/FastAPI—it tests the app instance directly without needing uvicorn running in the background.
    • This fixes the Connection Refused errors in CI.

@XxSURYANSHxX
Copy link
Author

hey @pradeeban @karthiksathishjeemain , as you can see that all the four checks are passing. The latest commit i made because we needed to fix two specific errors that were blocking the CI pipeline:

  1. Fixed the JavaScript tests: The testing library we were using (chai) was updated to version 5, which only works with the new "import" syntax (ESM). Since our project uses the standard "require" syntax (CommonJS), this caused the tests to crash. I fixed it by downgrading chai to version 4, which is fully compatible with our code.

  2. Fixed Formatting: The "Prettier" check was failing because some files weren't formatted correctly. I ran the formatter to clean up the code style so the check passes. Please have a look and let me know your thoughts. Thankyou

@pradeeban pradeeban merged commit 43c8322 into healthyinc:dev Feb 11, 2026
4 of 7 checks passed
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