0

I am coming up to speed on JS ES5/ES6 modules, how to test them, package them, etc. I am somewhat familiar with the module exports feature that node and npm wants, for instance, but in this case I am adding functionality onto JS prototypes as well as static methods on those base "types" (classes).

Just for example,

Array.prototype.suchAndSuch = ...

Or,

Array.thisThatAndTheOther = ...

Not necessarily, Array, per se, but you get the idea, hopefully.

I'm unclear as to how that necessarily gets included, imported, or otherwise "required" for use during a unit test?

Thanks!

mwpowellhtx
  • 351
  • 1
  • 9

1 Answers1

0

Extending a global object (which, just as a reminder, is still considered a bad practice!) basically is a side-effect of running the code and does not produce any new value to export. Your module would therefore have no export declaration, and to include it (declare the dependency) you would not import anything into a local binding, but rather just use

import './array_extensions';
Bergi
  • 630,263
  • 148
  • 957
  • 1,375