Skip to content

Cloud code not responding #7

@BernardZhao

Description

@BernardZhao

Hi, I was working on top of the Jasmine example using the test runner to test my Parse Cloud code, but I encountered an issue where whenever I run my Cloudcode, Jasmine times out. If I extend the timeout, the tests continue to run forever, without every receiving a response. Here is my testing code:

const { startParseServer, stopParseServer, dropDB } = require('parse-server-test-runner');

describe('cloudcode', () => {
   beforeAll((done) => {
    const appId = 'test';
    const masterKey = 'test';
    const javascriptKey = 'test';
    const cloud = __dirname + '/../cloud/main.js'
    
    startParseServer({ appId, masterKey, javascriptKey, cloud})
      .then(() => {
        Parse.initialize(appId, masterKey, javascriptKey);
        Parse.serverURL = 'http://localhost:30001/1';
      })
      .then(done).catch(done.fail);
    }, 100 * 60 * 2);

  afterAll((done) => {
    stopParseServer()
      .then(done).catch(done.fail);
  });

  beforeEach((done) => {
    dropDB()
      .then(done).catch(done.fail);
  });

  it('should work', (done) => {
    const q = new Parse.Query('_Installation')
    q.limit(5)
      .find({ useMasterKey: true })
      .then(console.log)
      .then(done).catch(done.fail);
  });

  it('test', (done) => {
    Parse.Cloud.run("test", {message: "hello"}).then(console.log).then(done).catch(done.fail);
  })

What is interesting is that the 'should work' test succeeds, so I know that a regular Query works. However, the one spec I added called 'test' does not. I know that my cloudcode is being referenced correctly, because if I remove the cloud argument and start the Parse server, I get an error response saying that particular cloud code function is undefined. Here is the cloud code that I am trying to run:

Parse.Cloud.define('test', async (request) => {
	return request.params.message
})

I have no idea how to begin debugging this, as I do not know how to access the logs of the Parse server generated by the test runner, and no idea what a lack of a response could mean. I am wondering if I am missing something simple in my definitions or configuration, any help would be appreciated!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions