compare-module-exports
Advanced tools
Comparing version 1.1.0 to 2.0.0
{ | ||
"name": "compare-module-exports", | ||
"version": "1.1.0", | ||
"version": "2.0.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
function generate(libraryName) { | ||
let hasError = false; | ||
let errors = []; | ||
const pushError = (err) => errors.push(err); | ||
@@ -8,3 +10,3 @@ function testFunction(a, b, file, name) { | ||
if (a.toString().indexOf('_could_be_any_') < 0) { | ||
console.error(name + ': in' + file + '\n\t\t' + a.toString() + '\n\tdoes not match\n\t\t' + b.toString()); | ||
pushError(name + ': in' + file + '\n\t\t' + a.toString() + '\n\tdoes not match\n\t\t' + b.toString()); | ||
throw new Error(libraryName + ': function argument mismatch: ' + file + ': ' + name); | ||
@@ -36,3 +38,3 @@ } | ||
if (typeOfA !== typeOfB) { | ||
console.error( | ||
pushError( | ||
libraryName + ': mock ' + mockFile + ' exports does not match a real file.' + | ||
@@ -47,3 +49,3 @@ ' Expected ' + typeOfB + ', got ' + typeOfA + '' | ||
} catch (e) { | ||
console.error(e.message, '\n'); | ||
pushError(e.message); | ||
hasError = true; | ||
@@ -56,3 +58,3 @@ } | ||
} catch (e) { | ||
console.error(e.message, '\n'); | ||
pushError(e.message); | ||
hasError = true; | ||
@@ -62,8 +64,10 @@ } | ||
} | ||
return hasError; | ||
return hasError ? errors : false; | ||
} | ||
function tryMatchExports(realExports, mockedExports, realFile, mockFile, options = {}) { | ||
if(matchExports(realExports, mockedExports, realFile, mockFile, options)){ | ||
return matchExports(realExports, { default: mockedExports }, realFile, mockFile, options) | ||
errors = []; | ||
if (matchExports(realExports, mockedExports, realFile, mockFile, options)) { | ||
errors = []; | ||
return matchExports(realExports, {default: mockedExports}, realFile, mockFile, options) | ||
} | ||
@@ -70,0 +74,0 @@ return false; |
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
3944
67