Comparing version 3.1.0 to 3.1.1
@@ -27,2 +27,3 @@ "use strict"; | ||
constructor() { | ||
// config.includeStack = true | ||
this._counts = 0; | ||
@@ -29,0 +30,0 @@ this._plannedCounts = 0; |
/** | ||
* @module Core | ||
*/ | ||
/// <reference types="node" /> | ||
import { EventEmitter } from 'events'; | ||
/** | ||
@@ -10,3 +12,3 @@ * List reporter to show the tests progress on stdout in | ||
private _store; | ||
constructor(emitter: any); | ||
constructor(emitter: EventEmitter); | ||
private get _indent(); | ||
@@ -54,6 +56,10 @@ /** | ||
/** | ||
* Cleans up the error stack | ||
*/ | ||
private _cleanupErrorStack; | ||
/** | ||
* Returns the error stack by filtering the japa core | ||
* lines from it. | ||
*/ | ||
private _getStack; | ||
private _formatErrorStack; | ||
/** | ||
@@ -60,0 +66,0 @@ * When test runner stops |
@@ -20,3 +20,3 @@ "use strict"; | ||
const right_pad_1 = __importDefault(require("right-pad")); | ||
const variable_diff_1 = __importDefault(require("variable-diff")); | ||
const jest_diff_1 = __importDefault(require("jest-diff")); | ||
const utils_1 = require("../utils"); | ||
@@ -107,9 +107,16 @@ const Contracts_1 = require("../Contracts"); | ||
if (actual && expected) { | ||
console.log(chalk_1.default.red(` Assertion Error: ${error.message}`)); | ||
variable_diff_1.default(actual, expected).text.split('\n').forEach((line) => { | ||
console.log(` ${line}`); | ||
}); | ||
const diff = jest_diff_1.default(expected, actual); | ||
const mainLine = this._cleanupErrorStack(error.stack)[1]; | ||
if (mainLine) { | ||
console.log(chalk_1.default.dim(` source => ${mainLine.trim().replace(/at\s+/, '')}`)); | ||
} | ||
if (diff) { | ||
console.log(diff); | ||
} | ||
else { | ||
console.log(chalk_1.default.red(` Assertion Error: ${error.message}`)); | ||
} | ||
return; | ||
} | ||
console.log(` ${this._getStack(error.stack)}`); | ||
console.log(` ${this._formatErrorStack(error.stack)}`); | ||
} | ||
@@ -150,7 +157,9 @@ /** | ||
/** | ||
* Returns the error stack by filtering the japa core | ||
* lines from it. | ||
* Cleans up the error stack | ||
*/ | ||
_getStack(errorStack) { | ||
_cleanupErrorStack(errorStack) { | ||
let prevIsNative = false; | ||
if (!errorStack) { | ||
return []; | ||
} | ||
return errorStack | ||
@@ -164,4 +173,13 @@ .split('\n') | ||
return !prevIsNative; | ||
}) | ||
.map((line, index) => { | ||
}); | ||
} | ||
/** | ||
* Returns the error stack by filtering the japa core | ||
* lines from it. | ||
*/ | ||
_formatErrorStack(errorStack) { | ||
if (!errorStack) { | ||
return; | ||
} | ||
return this._cleanupErrorStack(errorStack).map((line, index) => { | ||
if (index === 0) { | ||
@@ -171,4 +189,3 @@ return chalk_1.default.red(line); | ||
return chalk_1.default.dim(line); | ||
}) | ||
.join('\n'); | ||
}).join('\n'); | ||
} | ||
@@ -211,3 +228,3 @@ /** | ||
const failedHook = failedHooks[0]; | ||
console.log(`${chalk_1.default.red(` (${failedHook.title})`)} ${this._getStack(failedHook.error.stack)}`); | ||
console.log(`${chalk_1.default.red(` (${failedHook.title})`)} ${this._formatErrorStack(failedHook.error.stack)}`); | ||
} | ||
@@ -214,0 +231,0 @@ if (failedTests.length) { |
{ | ||
"name": "japa", | ||
"version": "3.1.0", | ||
"version": "3.1.1", | ||
"description": "Lean test runner for Node.js", | ||
@@ -43,7 +43,7 @@ "main": "build/index.js", | ||
"is-ci": "^2.0.0", | ||
"jest-diff": "^26.0.1", | ||
"ms": "^2.1.2", | ||
"retry": "^0.12.0", | ||
"right-pad": "^1.0.1", | ||
"time-span": "^4.0.0", | ||
"variable-diff": "^2.0.1" | ||
"time-span": "^4.0.0" | ||
}, | ||
@@ -50,0 +50,0 @@ "devDependencies": { |
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
140995
3633
+ Addedjest-diff@^26.0.1
+ Added@jest/types@26.6.2(transitive)
+ Added@types/istanbul-lib-coverage@2.0.6(transitive)
+ Added@types/istanbul-lib-report@3.0.3(transitive)
+ Added@types/istanbul-reports@3.0.4(transitive)
+ Added@types/node@22.9.1(transitive)
+ Added@types/yargs@15.0.19(transitive)
+ Added@types/yargs-parser@21.0.3(transitive)
+ Addedansi-regex@5.0.1(transitive)
+ Addeddiff-sequences@26.6.2(transitive)
+ Addedjest-diff@26.6.2(transitive)
+ Addedjest-get-type@26.3.0(transitive)
+ Addedpretty-format@26.6.2(transitive)
+ Addedreact-is@17.0.2(transitive)
+ Addedundici-types@6.19.8(transitive)
- Removedvariable-diff@^2.0.1
- Removedvariable-diff@2.0.2(transitive)