| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent b39dcde commit ff174b0
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -179,17 +179,30 @@ function jsToYaml(indent, name, value) { | |||
| 179 | 179 | code, | |
| 180 | 180 | failureType, | |
| 181 | 181 | message, | |
| 182 | + expected, | ||
| 183 | + actual, | ||
| 184 | + operator, | ||
| 182 | 185 | stack, | |
| 183 | 186 | } = value; | |
| 184 | 187 | let errMsg = message ?? '<unknown error>'; | |
| 185 | 188 | let errStack = stack; | |
| 186 | 189 | let errCode = code; | |
| 190 | + let errExpected = expected; | ||
| 191 | + let errActual = actual; | ||
| 192 | + let errOperator = operator; | ||
| 193 | + let errIsAssertion = isAssertionLike(value); | ||
| 187 | 194 | ||
| 188 | 195 | // If the ERR_TEST_FAILURE came from an error provided by user code, | |
| 189 | 196 | // then try to unwrap the original error message and stack. | |
| 190 | 197 | if (code === 'ERR_TEST_FAILURE' && kUnwrapErrors.has(failureType)) { | |
| 191 | 198 | errStack = cause?.stack ?? errStack; | |
| 192 | 199 | errCode = cause?.code ?? errCode; | |
| 200 | + if (isAssertionLike(cause)) { | ||
| 201 | + errExpected = cause.expected; | ||
| 202 | + errActual = cause.actual; | ||
| 203 | + errOperator = cause.operator ?? errOperator; | ||
| 204 | + errIsAssertion = true; | ||
| 205 | + } | ||
| 193 | 206 | if (failureType === kTestCodeFailure) { | |
| 194 | 207 | errMsg = cause?.message ?? errMsg; | |
| 195 | 208 | } | |
@@ -201,6 +214,14 @@ function jsToYaml(indent, name, value) { | |||
| 201 | 214 | result += jsToYaml(indent, 'code', errCode); | |
| 202 | 215 | } | |
| 203 | 216 | ||
| 217 | + if (errIsAssertion) { | ||
| 218 | + result += jsToYaml(indent, 'expected', errExpected); | ||
| 219 | + result += jsToYaml(indent, 'actual', errActual); | ||
| 220 | + if (errOperator) { | ||
| 221 | + result += jsToYaml(indent, 'operator', errOperator); | ||
| 222 | + } | ||
| 223 | + } | ||
| 224 | + | ||
| 204 | 225 | if (typeof errStack === 'string') { | |
| 205 | 226 | const frames = []; | |
| 206 | 227 | ||
@@ -229,4 +250,8 @@ function jsToYaml(indent, name, value) { | |||
| 229 | 250 | return result; | |
| 230 | 251 | } | |
| 231 | 252 | ||
| 253 | + function isAssertionLike(value) { | ||
| 254 | + return value && typeof value === 'object' && 'expected' in value && 'actual' in value; | ||
| 255 | + } | ||
| 256 | + | ||
| 232 | 257 | module.exports = { TapStream }; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -123,6 +123,9 @@ not ok 13 - async assertion fail | |||
| 123 | 123 | true !== false | |
| 124 | 124 | ||
| 125 | 125 | code: 'ERR_ASSERTION' | |
| 126 | + expected: false | ||
| 127 | + actual: true | ||
| 128 | + operator: 'strictEqual' | ||
| 126 | 129 | stack: |- | |
| 127 | 130 | * | |
| 128 | 131 | * | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -133,6 +133,9 @@ not ok 13 - async assertion fail | |||
| 133 | 133 | true !== false | |
| 134 | 134 | ||
| 135 | 135 | code: 'ERR_ASSERTION' | |
| 136 | + expected: false | ||
| 137 | + actual: true | ||
| 138 | + operator: 'strictEqual' | ||
| 136 | 139 | stack: |- | |
| 137 | 140 | * | |
| 138 | 141 | * | |
| Back | FazBrowse Home | New Git URL |
0 commit comments