Graphcool / graphcool-framework

Apache License 2.0
1.77k stars 131 forks source link

Errors returned in promises are not logged in test run #141

Open marktani opened 6 years ago

marktani commented 6 years ago

Issue by schickling Friday Sep 08, 2017 at 09:25 GMT Originally opened as https://github.com/graphcool/prisma/issues/371


Issue by marktani Tuesday May 30, 2017 at 11:49 GMT Originally opened as https://github.com/graphcool/api-bugs/issues/85


const stripe = require('stripe')('some-test-key')

module.exports = function (event) {
  const coupon = event.data
  return new Promise(function(resolve, reject) {
    return stripe.coupons.retrieve(
      coupon.key,
      function(err, response) {
        if (err) {
          console.log('wrong coupon code')
          resolve({error: 'wrong coupon code'})
        } else {
          console.log('right coupon code')
          console.log(response)
          resolve(event)
        }
      }
    )
  })
}

resolve({error: 'wrong coupon code'}) is never shown in the error logs in test run. triggering the function with a mutation logs the error correctly.

marktani commented 6 years ago

Comment by schickling Friday Sep 08, 2017 at 09:25 GMT


Comment by schickling Friday Jun 16, 2017 at 16:13 GMT


➤ Nilan Marktanner commented:

Try to reproduce.

marktani commented 6 years ago

Comment by schickling Friday Sep 08, 2017 at 09:25 GMT


Comment by marktani Saturday Jun 17, 2017 at 12:56 GMT


Executing this function in test run:

module.exports = function (event) {
  return new Promise(function(resolve, reject) {
    resolve({error: 'wrong coupon code'})
  })
}

Response:

{
  "timestamp": "2017-06-17T12:55:04.648Z",
  "isError": false,
  "duration": 210,
  "inline": {
    "event": "{\n  \"data\": {\n    \"Post\": {\n      \"updatedFields\": [\n        \"updatedAt\"\n      ],\n      \"node\": {\n        \"id\": \"cj41ab8mg00033k5wnlk2hg47\"\n      }\n    }\n  }\n}",
    "logs": [

    ]
  }
}