c
don't
s
Ha, Why not? Being able to run all of our unit tests for Updates/Upgrades/etc would be huge.
c
Yeah its sound great in theory but its difficult to do. You have to separate all of your business logic from actual netsuite calls. For example if you are calculating dates, you'd need a method that takes in data and doesn't do netsuite calls.
or encapsulate all of your netsuite calls inside other methods and mock those methods for return values that you want.. just don't test netsuite itself test your business logic only
You can use mocha/should or whatever node based framework you want after that to run the tests
s
Yeah, and that's kind of what we want to do. Test our business logic
Although being able to query the db to test for expected results would be nice
c
you'll have to mock your data
you shouldn't be testing db results as you aren't testing netsuite. You're testing your business logic.
s
Sounds like a monstrous headache to do, but since it is slow due to the end of the year, there's no better time to attempt it.
c
for example if you're calculating a custom value to set on a field on a record, you need to test the actual calculation not that it was set on a record. Once you set it on a record thats netsuite and is out of your control. You can say that your value(s) are correct though via unit tests
👍🏼 1
s
It'd be nice to test other logic as well based on a configuration of things
c
you just gotta separate the netsuite calls from the actual business logic.. so instead of having a method that uses suitescript api to get the values and do the calculation, you'd get the suitescript api values and pass them into a method that is independent of netsuite api calls
or you can use something like that NFT or your own methods that wrap native netsuite api methods so you can mock them
s
That'd be a lot of changes. Maybe something going forward we attempt with small things at first
Is that the fasttrack toolkit?
c
yeah
its an API wrapper so you can mock stuff
i don't recommend it but im sure someone will
s
Have you seen the help docs for
Project Sample: SuiteScript 2.0 Unit Testing
?
c
i dont believe so what does it suggest
thats pretty interesting actually
they are just mocking everything like i was suggesting
s
Yeah, I thought so too.
sorry, got pulled away on a meeting but it seems that you opened it up
h
c
That framework looks like its never testing anything
you mock everything so your results will always match what you'd expect
i could be totally wrong and probably am
s
meh, I use jest and NFT and while that makes unit testing easier in some cases NetSuite unit testing is still more challenging than the real world.