Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cloud code not responding #7

Open
BernardZhao opened this issue Jan 15, 2019 · 1 comment
Open

Cloud code not responding #7

BernardZhao opened this issue Jan 15, 2019 · 1 comment

Comments

@BernardZhao
Copy link

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
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant