unexpected
Advanced tools
Comparing version 4.1.4 to 4.1.5
@@ -124,5 +124,6 @@ var Assertion = require('./Assertion'); | ||
var error = new Error(); | ||
var error = new Error(); | ||
error._isUnexpected = true; | ||
error.output = output; | ||
this.serializeOutputToMessage(error); | ||
throw error; | ||
@@ -274,3 +275,3 @@ }; | ||
case 'bubble': | ||
return e; | ||
return errorWithMessage(e, e.output); | ||
default: | ||
@@ -304,2 +305,11 @@ throw new Error("Unknown error mode: '" + assertion.errorMode + "'"); | ||
Unexpected.prototype.serializeOutputToMessage = function (err) { | ||
var outputFormat = this.outputFormat(); | ||
if (outputFormat === 'html') { | ||
outputFormat = 'text'; | ||
err.htmlMessage = err.output.toString('html'); | ||
} | ||
err.message = err.output.toString(outputFormat); | ||
}; | ||
Unexpected.prototype.expect = function expect(subject, testDescriptionString) { | ||
@@ -329,8 +339,3 @@ var that = this; | ||
var wrappedError = handleNestedExpects(e, assertion); | ||
var outputFormat = that.outputFormat(); | ||
if (outputFormat === 'html') { | ||
outputFormat = 'text'; | ||
wrappedError.htmlMessage = wrappedError.output.toString('html'); | ||
} | ||
wrappedError.message = wrappedError.output.toString(outputFormat); | ||
that.serializeOutputToMessage(wrappedError); | ||
throw wrappedError; | ||
@@ -376,6 +381,9 @@ } | ||
} catch (e) { | ||
if (e._isUnexpected) { | ||
truncateStack(e, this.expect); | ||
var err = e; | ||
if (err._isUnexpected) { | ||
err = errorWithMessage(err, err.output); | ||
that.serializeOutputToMessage(err); | ||
truncateStack(err, this.expect); | ||
} | ||
throw e; | ||
throw err; | ||
} | ||
@@ -382,0 +390,0 @@ } else { |
{ | ||
"name": "unexpected", | ||
"version": "4.1.4", | ||
"version": "4.1.5", | ||
"author": "Sune Sloth Simonsen <sune@we-knowhow.dk>", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
479487
11701