I've used mocha js and some others in the past. It...
# suitescript
c
I've used mocha js and some others in the past. It really just depends on what you wanna do and how you've written your code. If you can abstract the business logic from any netsuite specific logic it makes it 1000X easier. No need to mock up all the netsuite calls which you shouldn't be doing anyways because you aren't testing netsuite you're testing your own business logic.
s
I've used same approach, completely separate and only test against business logic. The main issue is the bugs typically occur on version upgrades when the netsuite APIs change, but you can't test against that anyway.
c
Yeah you're right. Its not your job to test NetSuite's code so if it broke, then technically your tests are working.
Thats the best way i've found to do it so far without having to mock a ton of stuff.
Having testing/unit tests doesn't mean they are worthwhile tests.
d
@Craig as far as testing framework I'd recommend Jest since that is what NetSuite is providing some support for with https://github.com/oracle/netsuite-suitecloud-sdk/tree/master/packages/unit-testing we've began implementing testing using this structure and has been fruitful for us thus far
c
Was hoping for jest-cucumber
Most jest tests I’ve seen are tightly coupled to the implementation
I’ll take a look at the git page though and see how Oracle are trying to do it
d
what they have is pretty bare-bones thus far, but I assume they will be adding more support as time goes on and people actually begin using it - and more requests like yours start coming in though I assume can extend on top of whatever they have as well if you want to get more fancy with things, we've just kept things pretty vanilla thus far
b
they havent gotten very serious with it yet
their example code for code to test is
Copy code
/**
 * @NApiVersion 2.x
 * @NScriptType Suitelet
 * @NModuleScope SameAccount
 */
define(["N/record"], function(record) {
    return {
        onRequest: function(context) {
            if (context.request.method === 'GET') {
                const salesOrderId = context.request.parameters.salesOrderId;
                let salesOrderRecord = record.load({id: salesOrderId});
                salesOrderRecord.setValue({fieldId: 'memo', value: "foobar"});
                salesOrderRecord.save({enableSourcing: false});
            }
        }
    };
});
with them writing test on the onRequest method
that example pretty much fails for real code of any complexity since its basically testing the entire suitelet at once
s
NFT includes test configuration in the box.