parse-community / parse-server

Parse Server for Node.js / Express
https://parseplatform.org
Apache License 2.0
20.9k stars 4.78k forks source link

Request: In-Memory Storage adapter for mocking unit tests #5437

Closed mrmarcsmith closed 5 years ago

mrmarcsmith commented 5 years ago

Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is.

I'm bummed there isn't a "baked in" method for efficient unit testing without mongo.

Describe the solution you'd like A clear and concise description of what you want to happen.

I'm imagining an "In-Memory" storage adapter that contains ALL of the functionality of parse without any of the unit-testing "baggage" of mongo. For example, I could "save" an object, then query for the object but the "object" is stored in RAM instead of Mongo.

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Our current options for testing are:

  1. test the javascript function manually -> doesn't mock Parse objects or any other "more complex" parse server functionality example from @flovilmart
    
    // lib/jobs.js

module.exports = { job_1: function() {}, job_2: function() {} } ...

// main.js

var jobs = require('lib/jobs'); Object.keys(jobs).forEach(function(jobName) { Parse.Cloud.job(jobName, jobs[jobName]); });



2. spin up parse server with mongo-runner -> requires additional resources and slows tests down.

3. I'm open to additional suggestions if anyone has any!

**Additional context**
Add any other context or screenshots about the feature request here.
acinader commented 5 years ago

I've used and contributed to some 'fake mongos' for unit testing, but I've since switched over to using mongodb-runner instead as it is fast and easy.

the unit testing setup for parse-server is pretty messy, but if you look at how it is setup for the integration Parse-SDK-JS, it's pretty straight forward: https://github.com/parse-community/Parse-SDK-JS/tree/master/integration

is that helpful?

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.