NetSUMO
NetSuite Mocker - Unit test your SuiteScript 2.0 scripts.
click here
For SuiteScript 1.0 testing -continue reading.
For SuiteScript 2.0 testing -Installation
Pre Reqs
- Node
- NPM
Install using the command:
npm install netsumo
Getting Started
Create a new test file somewhere in your project, in our examples we are going to use jest as our testing framework, but NetSumo is test framework agnostic.
Create your awesome SuiteScript 2.0 file, in this example we are creating a user event script that sets a value on a record.
/** *@NApiVersion 2.x *@NScriptType UserEventScript */ ;
Create your new test file and add the following require statements:
const loadSuiteScriptModule NRecord = ;
The loadSuiteScriptModule
is super important, it allows us to load SuiteScript 2.0 modules (which use AMD module syntax) into Node.js (Which uses Common.js module syntax).
The NRecord
is our mocked N/record representation. We also have support for N/error, N/file, N/https, N/search, N/sso, we will build up these modules as they are needed. You can also use mocked objects to represent these modules if you wish.
Next step is to load our module using loadSuiteScriptModule
const loadSuiteScriptModule NRecord = ;const FulfilmentUserEventModule = //this is the path to the file in your local copy
Next step is to write our test!
const sinon = const loadSuiteScriptModule NRecord = ; const FulfilmentUserEventModule =
Next step is to run the test using our test runner and enjoy!