compare-module-exports
Advanced tools
Comparing version 1.0.0 to 1.0.1
{ | ||
"name": "compare-module-exports", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -19,3 +19,3 @@ function generate(libraryName) { | ||
if (typeOfA !== typeOfB) { | ||
throw new Error(libraryName + ': exported type mismatch: ' + file + ':' + name + '. Expected ' + typeOfB + ', got ' + typeOfB + ''); | ||
throw new Error(libraryName + ': exported type mismatch: ' + file + ':' + name + '. Expected ' + typeOfA + ', got ' + typeOfB + ''); | ||
} | ||
@@ -29,7 +29,18 @@ if (typeOfA === 'function') { | ||
hasError = false; | ||
if (typeof mockedExports !== typeof realExports) { | ||
throw new Error(libraryName + ': mock ' + mockFile + ' export does not match real file'); | ||
const typeOfA = typeof mockedExports; | ||
const typeOfB = typeof realExports | ||
if (typeOfA !== typeOfB) { | ||
console.error( | ||
libraryName + ': mock ' + mockFile + ' exports does not match a real file.' + | ||
' Expected ' + typeOfA + ', got ' + typeOfB + '' | ||
); | ||
return true; | ||
} | ||
if (typeof mockedExports === 'function') { | ||
test(mockedExports, realExports, realFile, 'exports'); | ||
try { | ||
test(mockedExports, realExports, realFile, 'exports'); | ||
} catch (e) { | ||
console.error(e.message, '\n'); | ||
hasError = true; | ||
} | ||
} else if (typeof mockedExports === 'object') { | ||
@@ -36,0 +47,0 @@ Object.keys(mockedExports).forEach(key => { |
3396
53