Home›Developer docs›Local development

Local development and testing

Updated Nov 13, 20262 min read

Run your SashiDo app's cloud code on your machine with a local Parse Server, and test functions and triggers automatically before you deploy.

Your cloud code is plain Node.js on Parse Server, so it runs on your machine the same way. Develop and test locally, then push to deploy.

Run a local server

You need Node.js and MongoDB (e.g. docker run -d -p 27017:27017 mongo:6). In your app's repository, install the Parse Server version your app runs (Runtime › Parse Server Version):

npm install express parse-server@6.5.11

Then a local.js next to cloud/:

// local.js: a local Parse Server with this repository's cloud code
const express = require('express');
const { ParseServer } = require('parse-server');

const port = 1337;

async function main() {
  const server = new ParseServer({
    databaseURI: process.env.DATABASE_URI || 'mongodb://localhost:27017/dev',
    appId: 'local',
    masterKey: 'local-master-key',
    serverURL: `http://localhost:${port}/1`,
    cloud: './cloud/main.js',
  });
  await server.start();

  const app = express();
  app.use(express.static('public'));
  app.use('/1', server.app);
  app.use('/', require('./cloud/main.js').app || ((req, res, next) => next()));
  app.listen(port, () => console.log(`Parse Server on http://localhost:${port}/1`));
}

main();
node local.js

Point your client at http://localhost:1337/1 with the app ID local. On Parse Server 3.x and 4.x there is no start(): mount the server itself, app.use('/1', server); the repository's own index.js is written that way.

Don't put your production keys or the production Database URL in local code: develop against a local database, or a copy.

Test automatically

With Jest and an in-memory MongoDB, each test run gets a fresh database:

npm install --save-dev jest mongodb-memory-server parse
// test/cloud.test.js
const express = require('express');
const { MongoMemoryServer } = require('mongodb-memory-server');
const { ParseServer } = require('parse-server');
const Parse = require('parse/node');

let mongo, http;

beforeAll(async () => {
  mongo = await MongoMemoryServer.create();
  const server = new ParseServer({
    databaseURI: mongo.getUri(),
    appId: 'test',
    masterKey: 'test-master-key',
    serverURL: 'http://localhost:1338/1',
    cloud: './cloud/main.js',
  });
  await server.start();
  http = express().use('/1', server.app).listen(1338);

  Parse.initialize('test', undefined, 'test-master-key');
  Parse.serverURL = 'http://localhost:1338/1';
});

afterAll(async () => {
  http.close();
  await mongo.stop();
});

test('a review needs 1 to 5 stars', async () => {
  const review = new Parse.Object('Review', { stars: 9 });
  await expect(review.save()).rejects.toThrow('stars must be 1 to 5');
});

test('averageRating averages the stars', async () => {
  await Parse.Object.saveAll([
    new Parse.Object('Review', { movie: 'Arrival', stars: 4 }),
    new Parse.Object('Review', { movie: 'Arrival', stars: 5 }),
  ]);
  expect(await Parse.Cloud.run('averageRating', { movie: 'Arrival' })).toBe(4.5);
});

Run them in CI before every push: see CI/CD.

Debug

  • console.log locally prints to your terminal; on SashiDo it goes to Core › Logs.
  • node --inspect local.js lets you set breakpoints in your editor or Chrome's DevTools.
  • Errors that happen only on SashiDo: compare the Parse Server version and the environment variables, then read the logs, or ask your assistant through MCP to find the failing code.

Reading this with an AI assistant? This page as Markdown.