Closed ergosarapu closed 7 years ago
I was not able to reproduce this. Could you please share a full minimal example or at least the exact command you used, dredd.yml
you used, dredd version, etc.?
I see you are using node v5.5.0. I tried it on older version of node, maybe that could be the issue.
Still not able to reproduce, even when using 5.5.0.
I have tried also older versions of node, but the result is same. Here is the current setup:
$ node -v
v5.5.0
$ dredd --version
dredd v1.0.4
I created minimal example with apiary.apib, dredd.yml and hooks.js files. The command I run is simply
$ dredd
I noticed that test results are reported to apiary successfully when setting transaction.fail=true in 'before' hook, so the issue is with 'after' hook.
Below are the contents of files. apiary.apib
FORMAT: 1A
# dredd-test
Hello World API
# Group Hello
## Hello [/message]
### Get Hello [GET]
+ Response 200 (application/json)
{"hello":"world"}
dredd.yml
reporter: apiary
custom:
apiaryApiKey: < REMOVED >
apiaryApiName: dreddtest2
dry-run: null
hookfiles: hooks.js
language: nodejs
sandbox: false
server: null
server-wait: 3
init: false
names: false
only: []
output: []
header: []
sorted: false
user: null
inline-errors: false
details: false
method: []
color: true
level: info
timestamp: false
silent: false
path: []
blueprint: apiary.apib
endpoint: 'http://private-34257-dreddtest2.apiary-mock.com'
hooks.js
var hooks = require('hooks');
hooks.after('Hello > Hello > Get Hello', function (transaction) {
transaction.fail = "Fail message";
});
I was able to reproduce this! :scream: Thank you @ergosarapu. This minimal example crashes on my computer as you reported. Reproduced on both Node 5 and Node 0.10 (didn't try other versions).
I believe this was fixed in #648. @ergosarapu could you please confirm?
@ergosarapu I didn't hear back, but feel free to re-open should you ever encounter this. Thank you very much for filing this and helping to debug the problem! 👍
Setting transaction fail inside after hook causes the JSON.stringify to throw error when using apiary reporter.
hooks.js:
Error and stacktrace: