jest-plugin-must-assert
Advanced tools
Comparing version 2.0.0 to 2.1.0
{ | ||
"name": "jest-plugin-must-assert", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"description": "Jest plugin for async tests", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "jest" | ||
"test": "jest", | ||
"harness": "node test-harness.js" | ||
}, | ||
"engines": { | ||
"node": ">= 12.17.0" | ||
}, | ||
"keywords": [ | ||
@@ -26,6 +30,6 @@ "jest", | ||
"execa": "^1.0.0", | ||
"jest": "^24.7.1", | ||
"jest-circus": "^24.7.1", | ||
"jest-cli": "^24.7.1", | ||
"meow": "^5.0.0", | ||
"jest": "^27.0.5", | ||
"jest-circus": "^27.0.5", | ||
"jest-cli": "^27.0.5", | ||
"meow": "^10.0.1", | ||
"prettier": "^1.16.4", | ||
@@ -32,0 +36,0 @@ "strip-ansi": "^5.2.0", |
@@ -23,2 +23,6 @@ # `jest-plugin-must-assert` | ||
or | ||
`yarn add -D jest-plugin-must-assert` | ||
For default behavior, add the plugin to your setup files. | ||
@@ -78,8 +82,10 @@ | ||
* Options: | ||
* @param {Number} originTestId The unique ID of the test where the task is oginating from | ||
* @param {Number} currentTestId The unique ID of the currently executing test | ||
* @param {String} testName The name of the test which triggered this event | ||
* @param {String} taskType The type of task being invoked (micro/macro task) | ||
* @param {String} taskSource The source of the taks ("promise.then", "setTimeout" etc) | ||
* @param {Object} logger The logger object (defaults to console) | ||
* @param {Number} originTestId The unique ID of the test where the task is oginating from | ||
* @param {Number} currentTestId The unique ID of the currently executing test | ||
* @param {String} testName The name of the test which triggered this event | ||
* @param {Object} task The task which is about to be invoked | ||
* @param {String} task.type The type of task being invoked (micro/macro task) | ||
* @param {String} task.source The source of the taks ("promise.then", "setTimeout" etc) | ||
* @param {Object} logger The logger object (defaults to console) | ||
* @param {Function} getStackTrace Returns the stack-trace of the stack | ||
* | ||
@@ -107,2 +113,3 @@ * @throws {Error} Default: throws. This function _may_ throw an error instead of logging it if | ||
}, | ||
/** | ||
@@ -112,2 +119,8 @@ * Logger DI. Used by the internal methods to log warnings/errors. Should match console API. | ||
logger, | ||
/** | ||
* Regex list of what functions should be REMOVED from the stack traces of cancelled tasks. | ||
* These are the default values. Overwriting this option removes these values | ||
*/ | ||
ignoreStack = [/Zone/, /zone\.js/, /node_modules/], | ||
}); | ||
@@ -114,0 +127,0 @@ ``` |
@@ -25,5 +25,5 @@ /** | ||
// The type of the task being acted upon [micro || macro]Task | ||
taskType, | ||
// Promise, setTimeout etc. | ||
taskSource, | ||
task, | ||
// Get the stack trace associated wit the task | ||
getStackTrace, | ||
}) { | ||
@@ -33,5 +33,6 @@ // Note that we do not use "testName" for this as they are not guaranteed to be | ||
if (originZoneId !== currentZoneId) { | ||
throw new Error( | ||
`Test "${testName}" is attempting to invoke a ${taskType}(${taskSource}) after test completion. See stack-trace for details.` | ||
const error = new Error( | ||
`Test "${testName}" is attempting to invoke a ${task.type}(${task.source}) after test completion. See stack-trace for details.` | ||
); | ||
throw error; | ||
} | ||
@@ -38,0 +39,0 @@ return true; |
@@ -85,2 +85,21 @@ /** | ||
let result = true; | ||
// Exposes the stack trace associated with the task | ||
function getStackTrace() { | ||
let stack; | ||
try { | ||
throw new Error(); | ||
} catch (e) { | ||
e.task = task; | ||
Zone.longStackTraceZoneSpec.onHandleError( | ||
delegate, | ||
current, | ||
target, | ||
e | ||
); | ||
stack = e.stack; | ||
} | ||
return stack; | ||
} | ||
try { | ||
@@ -91,5 +110,5 @@ result = onInvokeTask({ | ||
testName: name, | ||
taskType: task.type, | ||
taskSource: task.source, | ||
task, | ||
logger: logger, | ||
getStackTrace, | ||
}); | ||
@@ -96,0 +115,0 @@ } catch (e) { |
@@ -5,3 +5,3 @@ /** | ||
*/ | ||
const runCLI = require('jest-cli').runCLI; | ||
const runCLI = require('jest').runCLI; | ||
@@ -8,0 +8,0 @@ const [env = 'node'] = process.argv.slice(2); |
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
27022
695
140