Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
capture details in test parser
  • Loading branch information
ShMcK committed Apr 4, 2020
commit e61c14dfd3d7558c20ad72a069bb9366f32cedba
17 changes: 17 additions & 0 deletions src/services/testRunner/parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,21 @@ ok 3 sumItems should total numbers accurately
`
expect(parser(example).fails).toEqual([{ message: "sumItems shouldn't return NaN" }])
})
test('should capture error details', () => {
const example = `
not ok 1 package.json should have a valid "author" key
# AssertionError [ERR_ASSERTION]: no "author" key provided
# at Context.<anonymous> (test/packagejson.test.js:11:12)
# at processImmediate (internal/timers.js:439:21)
# tests 1
# pass 0
# fail 1
# skip 0
`
const result = parser(example)
expect(result.fails[0].message).toBe('package.json should have a valid "author" key')
expect(result.fails[0].details).toBe(`AssertionError [ERR_ASSERTION]: no "author" key provided
at Context.<anonymous> (test/packagejson.test.js:11:12)
at processImmediate (internal/timers.js:439:21)`)
})
})
3 changes: 2 additions & 1 deletion src/services/testRunner/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const parser = (text: string): ParserOutput => {
// check for error details
const isDetails = detect('details', line)
if (!!isDetails) {
const lineDetails: string = isDetails[2]
const lineDetails: string = isDetails[1].trim()
if (!currentDetails) {
currentDetails = lineDetails
} else {
Expand All @@ -63,6 +63,7 @@ const parser = (text: string): ParserOutput => {
}
}
}
addCurrentDetails()
return result
}

Expand Down