Handling Enums in Unit Tests
SuiteScript enums must be defined in the test file as an object with the exact values that are used in the script file. It is not required to list every possible value of the enum. If you don't define the enum with the exact values, an error will occur in your test file.
import script from "../src/FileCabinet/SuiteScripts/ue_exampleScript";
// import modules used
import record from 'N/recprd';
import Record from 'N/record/instance';
beforeEach(() => {
jest.clearAllMocks();
});
record.Type = {
SALES_ORDER: 'SALES_ORDER' // only define values used in your script
};
describe('Mocking SuiteScript dependencies', () => {
it('Should do something', () => {
// test code goes here
});
});