I am researching what it will take to add unit testing to my server side scripts. This is quite a process! One very large, very steep speed bump is how to import "library" js files into the scope of the file under test. This has brought me down the path of Module Loaders and the CommonJS "specification". During related research on the UG I came across the following question from user ironside:p.s. might I presume the 'ECMAScript 5 (except strict mode)' implies Rhino 1.7R3 on your end?
To which Evan replied:RE: EMCAScript?
Yes on the Rhino version
I then scuttled over to the release notes for Rhino 1.7R3 and was THRILLED when I read:A fully compliant CommonJS module implementation was contributed by Attila Szegedi.
Turns out Rhino1.7R4 features (among other things):Improved CommonJS module implementation
See, my issue is that I need to use a module loader when unit testing, this means I need to code for a module loader design. If I litter my code with require() and export references I need to be sure they don't blow up when they are deployed to NetSuite's application server. The idea that NetSuite Rhino has CommonJS support would make my life easier.But... it doesn't appear that the feature is being used.[CODE]UNEXPECTED_ERRORReferenceError: "require" is not defined. (SPR.SEA.Assistant.js$3110816$debugger.user#30)[/CODE]Evan, can you shed any light on this for me? Or anyone else unit testing server side scripts without using a browser (headless or not)? I had planned on running Node.js with a CommonJS loader and Jasmine or some similar test runner. Don't be fooled; it may *sound* like I know what I'm talking about but I really don't. Understanding unit testing JS files is making my head smoke and crack!