Skip to content

fix: resolve failing tests in src/index.test.ts (#30) - #32

Merged
JRustyHaner merged 1 commit into
mainfrom
iss30
Jul 9, 2026
Merged

fix: resolve failing tests in src/index.test.ts (#30)#32
JRustyHaner merged 1 commit into
mainfrom
iss30

Conversation

@JRustyHaner

Copy link
Copy Markdown
Contributor
  • Export app instance from index.ts for supertest usage
  • Use request(app) instead of request('http://localhost:4000') to avoid race condition with async server startup
  • Add mocks for initSchema, SampleModelIngestor, and auth modules
  • Mock process.exit to prevent tests from terminating
  • Move second test inside describe block (was incorrectly placed outside)

- Export app instance from index.ts for supertest usage
- Use request(app) instead of request('http://localhost:4000') to avoid
  race condition with async server startup
- Add mocks for initSchema, SampleModelIngestor, and auth modules
- Mock process.exit to prevent tests from terminating
- Move second test inside describe block (was incorrectly placed outside)
@JRustyHaner
JRustyHaner requested a review from Copilot July 9, 2026 16:46
@JRustyHaner JRustyHaner linked an issue Jul 9, 2026 that may be closed by this pull request
@JRustyHaner
JRustyHaner merged commit 69a0786 into main Jul 9, 2026
2 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adjusts the backend entrypoint and its Vitest suite so HTTP endpoints can be tested via Supertest without relying on a race-prone real network listener.

Changes:

  • Export the Express app from src/index.ts for direct Supertest usage.
  • Update tests to use request(app) and add mocks for DB/schema/ingestion/auth to avoid external side effects.
  • Prevent accidental test termination by stubbing process.exit, and fix test structure by placing the second test inside the describe block.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
backend/src/index.ts Exports the Express app instance so it can be imported by tests.
backend/src/index.test.ts Switches to request(app) and adds additional mocks to stabilize the test environment.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread backend/src/index.ts
dotenv.config();

const app = express();
export const app = express();
Comment thread backend/src/index.test.ts
Comment on lines +53 to +55
// 7. Mock process.exit to prevent tests from exiting
vi.spyOn(process, "exit").mockImplementation((() => undefined) as never);

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.

Backend Maintenance: Failing Test (index.ts)

2 participants