Has someone here been using Jest on SuiteCloud pro...
# suitescript
g
Has someone here been using Jest on SuiteCloud projects? How is your experience so far?
e
Yep, I use it in all my projects, personal and professional. My experience has been highly positive. It is challenging to write useful unit tests for very procedural code as the more SuiteScript API you have to mock, the less useful and more verbose your tests will be. In that way, adding unit tests might force you to rethink how your code is structured, but I think that's overall a good thing.
👌 3
m
I come from deep experience in Salesforce where unit tests are required. Personally I love the ability to write and run SuiteScript tests locally with Jest using
npm test
. This is IMO one of NetSuite’s strengths.
2
n
I'd be interested to see a clear/easy to follow article, on how to set this up and write tests. Do either of you know of such a thing?
e
I'm not aware of one. I suppose the challenge with such an article is knowing an appropriate starting point for the audience. If one is already familiar with npm packages and unit testing in general, it's fairly straightforward; if not, there's a lot of background to build in.
n
I'm not confident with npm, never had/seen a reason to use it commercially. Is it now everyone says, "working on NS nearly 12 years and never needed to, what 😮 ?" Am I missing out on something... apart from, ehm, Jest? 😄
😅 1
e
Can't say whether you're missing out or not. I use
npm
for all my SDF Projects to run Jest (unit tests + code coverage), ESLint (syntax + style checking), JSDoc (documentation generation), and as the backbone of any CI/CD pipelines for said Projects. If it's you all by your lonesome working in one NetSuite Account, you might not need any of those things. The larger a team and its codebase grows, the more investments in something like
npm
, CI/CD, and all the associated tooling pays off, but certainly
npm
is not some magic solution for every situation.
n
I'm intrigued, are you producing html documentation for your projects using JSDocs?
e
For something like an integration API (i.e. Restlets), yes
n
That interests me. I've played around with this in the past and managed to generate some reasonable results but nothing that seemed to work across projects. (By that I mean it worked on one project but using the same approach failed on another). I ended up with a nice index page with the various project scripts and functions for each. I should spend more time getting to grips with this I feel. Thanks for replying.
As a test/investigation I managed to write a very simple UE and a test to run, funny how much pleasure a simple success like this can bring 😄 I'm sure it's probably more verbose than it needs to be but it's a promising start. (sorry to hijack the thread 😉 )
1
❤️ 2