Skip to content

Handle failed assertions and include them in reports #86

Closed
@rupl

Description

@rupl

I think it would be really great to handle failed assertions and log them the same way a successful run is logged. We could even color-code the data points that fail assertions.

This is the output I see when I set an assertion that fails. In this case I set assert-requests to a very low number in the options object of the Gruntfile:

$ grunt phantomas:requests
Running "phantomas:requests" (phantomas) task

PHANTOMAS EXECUTION(S) STARTED.
>> 5 Phantomas execution(s) done -> checking results:
>> SOMETHING WENT WRONG...
>> TypeError: Cannot call method 'value' of undefined
>> TypeError: Cannot call method 'value' of undefined
>>     at null.<anonymous> (.../grunt/phantomas/node_modules/grunt-phantomas/tasks/lib/phantomas.js:377:50)
>>     at tryCatch2 (.../grunt/phantomas/node_modules/grunt-phantomas/node_modules/bluebird/js/main/util.js:74:19)
>>     at Promise$_resolveFromResolver [as _resolveFromResolver] (.../grunt/phantomas/node_modules/grunt-phantomas/node_modules/bluebird/js/main/promise.js:608:13)
>>     at new Promise (.../grunt/phantomas/node_modules/grunt-phantomas/node_modules/bluebird/js/main/promise.js:88:37)
>>     at Phantomas.formResult (.../grunt/phantomas/node_modules/grunt-phantomas/tasks/lib/phantomas.js:372:10)
>>     at tryCatch1 (.../grunt/phantomas/node_modules/grunt-phantomas/node_modules/bluebird/js/main/util.js:64:19)
>>     at Promise$_callHandler [as _callHandler] (.../grunt/phantomas/node_modules/grunt-phantomas/node_modules/bluebird/js/main/promise.js:708:13)
>>     at Promise$_settlePromiseFromHandler [as _settlePromiseFromHandler] (.../grunt/phantomas/node_modules/grunt-phantomas/node_modules/bluebird/js/main/promise.js:724:18)
>>     at Promise$_settlePromiseAt [as _settlePromiseAt] (.../grunt/phantomas/node_modules/grunt-phantomas/node_modules/bluebird/js/main/promise.js:896:14)
>>     at Promise$_fulfillPromises [as _fulfillPromises] (.../grunt/phantomas/node_modules/grunt-phantomas/node_modules/bluebird/js/main/promise.js:1041:14)

I started hunting around for a solution and noticed that metrics doesn't exist when the assertion fails, which is the undefined reported in the Grunt output. Instead the promise results argument contains a small-ish object with only a couple properties: the Error code (mine was Error 1), and a stack trace.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions