Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jest-plugin-must-assert

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jest-plugin-must-assert - npm Package Compare versions

Comparing version 2.2.0 to 3.0.0

5

package.json
{
"name": "jest-plugin-must-assert",
"version": "2.2.0",
"version": "3.0.0",
"description": "Jest plugin for async tests",
"main": "index.js",
"scripts": {
"test": "jest"
"test": "jest",
"harness": "node test-harness.js"
},

@@ -9,0 +10,0 @@ "engines": {

19

README.md

@@ -81,8 +81,10 @@ # `jest-plugin-must-assert`

* 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
*

@@ -98,4 +100,3 @@ * @throws {Error} Default: throws. This function _may_ throw an error instead of logging it if

testName,
taskType,
taskSource,
task,
}) {

@@ -106,3 +107,3 @@ // This is the default implementation of onInvokeTask. The error thrown will

throw new Error(
`Test "${testName}" is attempting to invoke a ${taskType}(${taskSource}) after test completion. Ignoring`
`Test "${testName}" is attempting to invoke a ${task.type}(${task.source}) after test completion. Ignoring`
);

@@ -109,0 +110,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);

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc