Skip to content

Commit

Permalink
Merge pull request #32 from kmnaid/addHookState
Browse files Browse the repository at this point in the history
Adds state of hook to Json output
  • Loading branch information
fijijavis authored Jul 16, 2019
2 parents 293021d + a1b317a commit 41cf8db
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/mapHooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module.exports = function (suiteHooks) {
hookResult.title = hook.title
hookResult.associatedSuite = hook.parent
hookResult.associatedTest = hook.currentTest
hookResult.state = hook.errors.length ? hook.state : 'passed'

if (hook.error) {
if (hook.error.type) {
Expand Down
18 changes: 14 additions & 4 deletions test/mapHooks.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,16 @@ const hookStub = [{
'cid': '0-0',
'title': '"before each" hook',
'parent': 'Sample Suite',
'errors': [],
'end': '2019-03-07T19:15:49.427Z'
'errors':
[{ 'message': 'expected 1 to equal 6',
'stack':
'AssertionError: expected 1 to equal 6',
'type': 'AssertionError',
'expected': 6,
'actual': 1
}],
'end': '2019-03-07T19:15:49.427Z',
'state': 'failed',
},
{
'type': 'hook',
Expand All @@ -32,14 +40,16 @@ describe('Tests to validate mapping hooks', () => {
end: hookStub[0].end,
duration: hookStub[0]._duration,
title: hookStub[0].title,
associatedSuite: hookStub[0].parent
associatedSuite: hookStub[0].parent,
state: hookStub[0].state
})
expect(hookData[1]).toMatchObject({
start: hookStub[1].start,
end: hookStub[1].end,
duration: hookStub[1]._duration,
title: hookStub[1].title,
associatedSuite: hookStub[1].parent
associatedSuite: hookStub[1].parent,
state: 'passed'
})
})
})

0 comments on commit 41cf8db

Please sign in to comment.