@drakensoftware/magicmock
Advanced tools
Comparing version 1.3.1 to 1.3.2
"use strict"; | ||
//This file loads dynamically MagicMock only if it is needed | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.callMocked = exports.mockClass = exports.mockFunction = void 0; | ||
function iAmInNode() { | ||
return typeof window === 'undefined'; | ||
} | ||
function iAmTesting() { | ||
return process?.env?.NODE_ENV === 'test'; | ||
} | ||
function iAmDisabled() { | ||
return process?.env?.DISABLE_MM; | ||
} | ||
function shouldIRun() { | ||
return iAmInNode() && iAmTesting() && !iAmDisabled(); | ||
} | ||
function mockFunction(thisArg, identifier, fn) { | ||
if (!process.env.NODE_ENV || process.env.NODE_ENV !== 'test') | ||
if (!shouldIRun()) | ||
return fn; | ||
@@ -15,3 +28,3 @@ else { | ||
function mockClass(thisArg, identifier, obj) { | ||
if (!process.env.NODE_ENV || process.env.NODE_ENV !== 'test') | ||
if (!shouldIRun()) | ||
return obj; | ||
@@ -25,8 +38,12 @@ else { | ||
exports.mockClass = mockClass; | ||
function callMocked(func, identifier) { | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const module = require('./MagicMock'); | ||
return module.callMocked(func, identifier); | ||
async function callMocked(func, identifier) { | ||
if (!shouldIRun()) | ||
return await func(); | ||
else { | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const module = require('./MagicMock'); | ||
return module.callMocked(func, identifier); | ||
} | ||
} | ||
exports.callMocked = callMocked; | ||
//# sourceMappingURL=Loader.js.map |
{ | ||
"name": "@drakensoftware/magicmock", | ||
"version": "1.3.1", | ||
"version": "1.3.2", | ||
"description": "Create your mocks automagically", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances 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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
21239
292
4