Add Parse Server + in-memory Mongo integration tests - #277
Merged
sadortun merged 1 commit intoAug 14, 2026
Merged
Conversation
Add an opt-in integration suite (yarn test:integration) that runs against a real Parse Server backed by mongodb-memory-server, kept separate from the fast unit suite (yarn test) to avoid the heavy deps/binary download in the default path. - jest.integration.config.ts with globalSetup/globalTeardown that boot Mongo + Parse Server once in Jest's main process (parse-server's dynamic imports fail inside a test-file VM); workers get the URL/creds via env and a WebCrypto window shim so SecureObject/CryptoUtils run. - Query: CRUD, findBy/findOneBy, getObjectById (id/pointer/not-found), count, findAll, each, distinct, aggregate, findOrCreate incl. a concurrency test that proves the per-class mutex prevents duplicate creation, and CacheableQuery caching. - SecureObject: encrypt-at-rest + transparent decrypt-on-read round-trip, saveAll, and already-encrypted guard; CryptoUtils PBKDF2/encrypt/decrypt round-trip, random-IV, and wrong-key failure using real WebCrypto. Adds parse-server and mongodb-memory-server as devDependencies. Co-authored-by: Samuel Denis-D'Ortun <sam@sddproductions.com>
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
sadortun
merged commit Aug 14, 2026
328f9b4
into
cursor/fix-utils-bugs-and-tests-dc58
2 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an opt-in integration test suite that runs the Parse-backed and crypto code against a real Parse Server on an in-memory MongoDB (
mongodb-memory-server). This complements the REST-mock unit tests (which verify our logic) by validating real query semantics, thefindOrCreatemutex under concurrency, and — most importantly — the actualSecureObject/CryptoUtilsencrypt→save→query→decrypt round-trip, which mocks can't exercise.Design decisions
yarn test. These tests pull in heavy dev-deps (parse-server, plusmongodb-memory-serverwhich downloads a Mongo binary) and are slower, so they run viayarn test:integrationwith their ownjest.integration.config.tsand*.itest.tsnaming. The default unit run stays fast and CI-safe (unchanged at 145 tests).globalSetup, not in a test file.parse-server.start()uses dynamicimport(), which fails inside Jest's per-file VM (dynamic import callback was invoked without --experimental-vm-modules).globalSetup/globalTeardownrun in Jest's main Node process where native dynamic import works; workers receive the URL/credentials via env vars.window.crypto/window.performance; the setup exposes Node's WebCrypto +perf_hooksunderwindowsoSecureObject/CryptoUtilsrun unchanged.What's covered (17 tests)
findBy,findOneBy,getObjectById(id / pointer / not-found),count,findAll,each,distinct,aggregate(server-side pipeline),findOrCreate(create + existing), a concurrency test proving the per-class mutex prevents duplicate creation, andCacheableQuerycaching.saveAll; already-encrypted guard.Is more complete testing worth it?
Yes, for these modules specifically — they're security-critical and their real behavior (encryption, Mongo query semantics, concurrency) is exactly what unit mocks cannot prove. The cost is contained by making the suite opt-in. I would not push for broader integration coverage of the pure utility modules (
ArrayUtils,StringUtils, etc.) — unit tests already cover those at 100% and a server adds no value there.Validation
yarn test:integration— 2 suites / 17 tests pass (~1s after server boot).yarn test(unit) — still 14 suites / 145 tests (integration files are not picked up).yarn build(tsc) — 0 errors.yarn lint— clean.Notes
parse-serverwrites a./logsfolder at startup regardless ofsilent; added/logsto.gitignore.mongodb-memory-serverbinary download (or pre-provisionMONGOMS_SYSTEM_BINARY).