parse-mockdb provides a mocked RESTController for the Parse JavaScript SDK, specifically compatible with version `2.0+`. It is primarily designed for unit testing Parse-dependent applications by allowing developers to simulate Parse backend operations (CRUD, queries, relations) locally without requiring an actual Parse Server instance. The current stable version is 0.4.0, which targets Parse JS SDK 2.x. While it supports many core Parse features like basic CRUD, various query operators (e.g., $exists, $in, $regex), and Parse.Relation, it currently lacks support for Parse class-level permissions, ACLs, and special classes like Parse.User or Parse.Role. The release cadence appears to be driven by breaking changes and updates to align with the Parse SDK, with significant breaking changes in versions 0.3.0 and 0.4.0.
npm install parse-mockdbVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to set up `parse-mockdb`, mock the Parse SDK, perform basic CRUD operations, and then clean up the mock database. It highlights the typical workflow for unit testing Parse applications.
For Parse JS SDK 1.6+, use `npm install parse-mockdb@~0.3.0`. For Parse JS SDK 2.x+, use `npm install parse-mockdb`.
Update calls from `ParseMockDB.mockDB()` to `ParseMockDB.mockDB(Parse);` ensuring `Parse` is your initialized Parse SDK object.
Always load `parse-mockdb` explicitly using `const ParseMockDB = require('parse-mockdb');` and refer to `ParseMockDB` directly.Refactor code to use standard asynchronous promise handling (e.g., `async/await` or `.then/.catch`) instead of the removed synchronous utility.
Structure tests to avoid dependencies on unimplemented features, or consider integrating with a full Parse Server for tests requiring these advanced functionalities.
Ensure `const Parse = require('parse-shim');` and then call `ParseMockDB.mockDB(Parse);`.Add `const Parse = require('parse-shim');` at the top of your test file or ensure Parse is globally available if that's your setup.Ensure `Parse.initialize()` is called with placeholder values (appId, jsKey, masterKey) before mocking, as the Parse SDK sometimes requires this even when mocking.