npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

netsumo

v3.6.7

Published

NetSUite MOcker

Downloads

462

Readme

NetSUMO

NetSuite Mocker - Unit test your SuiteScript 2.0 scripts.

For SuiteScript 1.0 testing - click here

For SuiteScript 2.0 testing - continue reading.


Build Status

NPM


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
 */
 define(['N/record'], function(record) {

  function beforeSubmit(context) {
      if(context.type == context.UserEventType.CREATE) {
        var fulfilmentRecord = context.newRecord;

        fulfilmentRecord.setValue({
          fieldId:"custbody_a_custom_field",
          value:"Hello World!"
        })
      }
  }

  return {
      beforeSubmit: beforeSubmit
  };

});

Create your new test file and add the following require statements:

const {loadSuiteScriptModule, NRecord} = require('netsumo');

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} = require('netsumo');
const FulfilmentUserEventModule = loadSuiteScriptModule('src/userevent/Fulfilment_UE.js') //this is the path to the file in your local copy

Next step is to write our test!

const sinon = require('sinon')
const {loadSuiteScriptModule, NRecord} = require('netsumo');

const FulfilmentUserEventModule = loadSuiteScriptModule('src/userevent/Fulfilment_UE.js')

test("It sets my custom field value to Hello World!", ()=>{
  //create a new instance of N/record
  var record = new NRecord();

  //create a new item fulfilment record
  var itemFulfilmentRecord = record.create({
    type:record.Type.ITEM_FULFILLMENT,
    id:1234,
    defaultValues:{
      shipmethod:{
        value:1,
        text:"DPD"
      }
      ... //populate default values here
    },
    sublists:{
      'package':[{
        packageweight:10,
        sys_id:1232342342434,
        sys_parentid:89842893742837,
        pkgWeightUnit:"lbs",
        packagedescr:"some description"
      }]
      ... //populate sublists here
    }
  })

  //Instantiate our module, passing in our dependencies
  const fulfilmentUserEvent = FulfilmentUserEventModule({
    "N/record":record
  })

  //Execute the beforeSubmit method, passing in our context
  fulfilmentUserEvent.beforeSubmit({
    type:"create",
    UserEventType:{
      CREATE:"create",
      EDIT:"edit"
    },
    newRecord:itemFulfilmentRecord
  })

  //Perform assertions
  expect(itemFulfilmentRecord.getValue("custbody_a_custom_field").toBe("Hello World!")
})

Next step is to run the test using our test runner and enjoy!