Guest User

Untitled

a guest
Nov 19th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. /*
  2. * Conditionally export a function for testing
  3. *
  4. * Usage:
  5. * (src/file.js)
  6. * $test(privateHelper, module, [nameForExport])
  7. *
  8. * (src/file_test.js)
  9. * import { name } from './file'
  10. *
  11. */
  12.  
  13. export const $test = (func, mod, name) => {
  14. if (process.env.NODE_ENV === 'test') {
  15. mod.exports[name || func.name] = func;
  16. }
  17. return func;
  18. };
Add Comment
Please, Sign In to add comment