Skip to content

fix(datasource-mongo): fix flaky create integration test#1550

Merged
Scra3 merged 2 commits intomainfrom
fix/datasource-mongo-flaky-test
Apr 14, 2026
Merged

fix(datasource-mongo): fix flaky create integration test#1550
Scra3 merged 2 commits intomainfrom
fix/datasource-mongo-flaky-test

Conversation

@Scra3
Copy link
Copy Markdown
Member

@Scra3 Scra3 commented Apr 14, 2026

Summary

  • Await connection.dropDatabase() (was fire-and-forget, causing race condition)
  • Add explicit await Movie.createCollection() before saving data

The test was flaky because MongoDB introspection could run before the collection existed, resulting in "Collection 'movies' not found" with an empty collection list.

Matches the pattern already used in index.integration.test.ts.

Test plan

  • Fix matches working pattern from index.integration.test.ts

🤖 Generated with Claude Code

Note

Fix flaky beforeEach setup in MongoDB create integration tests

Awaits the dropDatabase call and adds an awaited createCollection call before seeding the Inception document in the beforeEach hooks of create.integration.test.ts and index.ssh.integration.test.ts. This ensures the database is fully dropped and the Movies collection exists before each test runs, eliminating a race condition that caused intermittent failures.

Macroscope summarized 13a37b7.

alban bertolini and others added 2 commits April 14, 2026 11:12
- Await connection.dropDatabase() instead of fire-and-forget
- Add explicit Movie.createCollection() before saving data

The test was flaky because introspection could run before the
collection existed, resulting in "Collection 'movies' not found".

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@qltysh
Copy link
Copy Markdown

qltysh bot commented Apr 14, 2026

Qlty

Coverage Impact

This PR will not change total coverage.

🚦 See full report on Qlty Cloud »

🛟 Help
  • Diff Coverage: Coverage for added or modified lines of code (excludes deleted files). Learn more.

  • Total Coverage: Coverage for the whole repository, calculated as the sum of all File Coverage. Learn more.

  • File Coverage: Covered Lines divided by Covered Lines plus Missed Lines. (Excludes non-executable lines including blank lines and comments.)

    • Indirect Changes: Changes to File Coverage for files that were not modified in this PR. Learn more.

@Scra3 Scra3 merged commit ef90e90 into main Apr 14, 2026
29 checks passed
@Scra3 Scra3 deleted the fix/datasource-mongo-flaky-test branch April 14, 2026 09:22
forest-bot added a commit that referenced this pull request Apr 14, 2026
## @forestadmin/datasource-mongo [1.6.9](https://github.com/ForestAdmin/agent-nodejs/compare/@forestadmin/datasource-mongo@1.6.8...@forestadmin/datasource-mongo@1.6.9) (2026-04-14)

### Bug Fixes

* **datasource-mongo:** fix flaky create integration test ([#1550](#1550)) ([ef90e90](ef90e90))
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