parse-server-test-runner icon indicating copy to clipboard operation
parse-server-test-runner copied to clipboard

Cloud code not responding

Open BernardZhao opened this issue 6 years ago • 1 comments

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!

BernardZhao avatar Jan 15 '19 22:01 BernardZhao

After extending the timeout time even further, I eventually got this error:

Failures:
1) cloudcode test
  Message:
    Failed: XMLHttpRequest failed: "Unable to connect to the Parse API"
  Stack:


2 specs, 1 failure
Finished in 607.678 seconds

BernardZhao avatar Jan 16 '19 03:01 BernardZhao