* Return a character diff for `err`. * * @api private * @param {String} actual * @param {String} expected * @return {string} the diff
(actual, expected)
| 2260 | * @return {string} the diff |
| 2261 | */ |
| 2262 | function errorDiff(actual, expected) { |
| 2263 | return diff |
| 2264 | .diffWordsWithSpace(actual, expected) |
| 2265 | .map(function(str) { |
| 2266 | if (str.added) { |
| 2267 | return colorLines('diff added', str.value); |
| 2268 | } |
| 2269 | if (str.removed) { |
| 2270 | return colorLines('diff removed', str.value); |
| 2271 | } |
| 2272 | return str.value; |
| 2273 | }) |
| 2274 | .join(''); |
| 2275 | } |
| 2276 | |
| 2277 | /** |
| 2278 | * Color lines for `str`, using the color `name`. |
no test coverage detected