0

I'm using a promise to wait on a Facebook Graph response in the middle of a Mocha test. I'm wondering why the expect function is not actually checking that the data is included in the response.

I see resolve in the console, suggesting the graph call worked and the promise resolved, but the test passes, even though the event does not include the random data in the expect(data).to.include statement. How can I get test the response when the promise resolves?

     var promise = new Promise(function(resolve, reject) {
var eventFB1 = graph.get('132166232459578/posts',
  {limit: 1,
    access_token: 't0k3n'
  });

  if (typeof eventFB1 !== 'undefined') {
    resolve(eventFB1);
    console.log('resolve');
  }
  else {
    reject(Error("It broke"));
    console.log('reject');

  }
});

return promise.then(function(data) {
    expect(data).to.include( 'Event name: Testing London eveng 23498723rstni' );
    console.log(data);
});
KindOfGuy
  • 3,081
  • 5
  • 31
  • 47
  • 1
    while testing, you should probably fake the call to facebook. – jibe Aug 03 '16 at 09:47
  • I want to test that the post is actually being made to Facebook, all the wiring is working. It is a full acceptance test. I initially wanted to look at the post in the browser, but webdriver doesn't allow you to reject browser notifications, so I am checking it with the API now. – KindOfGuy Aug 03 '16 at 17:55

0 Answers0