You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The afterSave hook in Parse MockDB behaves differently to a real Parse Server (v4.4.0 at time of writing).
In a real server, the afterSave hook will provide the original object from before the save as request.original, as well as the saved object in request.object as expected. In other words, it should provide the same objects on the request object as you would see in beforeSave.
Thus, any cloud code which relies on using this information to perform certain actions when particular data has changed isn't able to be unit tested via Parse MockDB.
Problem
The
afterSave
hook in Parse MockDB behaves differently to a real Parse Server (v4.4.0 at time of writing).In a real server, the
afterSave
hook will provide the original object from before the save asrequest.original
, as well as the saved object inrequest.object
as expected. In other words, it should provide the same objects on therequest
object as you would see inbeforeSave
.Thus, any cloud code which relies on using this information to perform certain actions when particular data has changed isn't able to be unit tested via Parse MockDB.
Testing
main.js
test_context.js
The cloud code just logs out the
request.original
andrequest.object
in thebeforeSave
hook and theafterSave
hook.The test script just creates an object and then updates it.
Run the test Parse Server via Docker as below:
After running the test script in a separate terminal:
You will see this in the server logs (split into two chunks: (1) create then (2) update):
Create
Update
As you can see in the final part of the logs above, the original object and the saved object are sent through to
afterSave
.The text was updated successfully, but these errors were encountered: