Mocking SuiteScript Methods and Objects in Unit Tests
Mocking is the process of creating arbitrary values to imitate the behavior of the script. In SuiteScript, we can mock all object and module members that are used in a script. This could include methods, objects, and properties.
We imitate the behavior of SuiteScript dependencies to provide context to Jest. To imitate this behavior, we use built in Jest functions that allow us to create a variation of outcomes.
To mock a SuiteScript method, you need to use a Jest mock function to initiate a test. You should familiarize yourself with Jest mock functions to have a better understanding of mocking. For a complete list of Jest mock functions, see Jest Mock Functions.