Skip to content

Commit

Permalink
fix: improve the test error to include the original stack trace
Browse files Browse the repository at this point in the history
  • Loading branch information
Ronald Holshausen committed Oct 30, 2020
1 parent 21774de commit c14cb97
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions src/v3/pact.ts
Expand Up @@ -199,17 +199,25 @@ export class PactV3 {
return val
}
})
.catch((err: any) => {
.catch((err: Error) => {
const testResult = this.pact.getTestResult(result.mockServer.id)
let error = "Test failed for the following reasons:"
error += "\n\n Test code failed with an error: " + err.message
if (testResult.mockServerError) {
error += "\n\n " + testResult.mockServerError
}
if (testResult.mockServerMismatches) {
error += "\n\n " + generateMockServerError(testResult, " ")
if (testResult.mockServerError || testResult.mockServerMismatches) {
let error = "Test failed for the following reasons:"
error += "\n\n Test code failed with an error: " + err.message
if (err.stack) {
error += "\n" + err.stack + "\n"
}

if (testResult.mockServerError) {
error += "\n\n " + testResult.mockServerError
}
if (testResult.mockServerMismatches) {
error += "\n\n " + generateMockServerError(testResult, " ")
}
return Promise.reject(new Error(error))
} else {
return Promise.reject(err)
}
return Promise.reject(new Error(error))
})
.finally(() => {
this.pact.shutdownTest(result)
Expand Down

0 comments on commit c14cb97

Please sign in to comment.