Anyone doing unit testing with Jest and SuiteScrip...
# dev-ops
e
Anyone doing unit testing with Jest and SuiteScript? I'm still a neophyte with unit testing. I have a custom module under test which depends on another custom module. That second module uses
N/runtime.accountId
. During my unit tests for the first module, I want to vary the return value of
runtime.accountId
. How would I go about that?
👀 3
d
I've done a decent amount in the past difficult to say exactly without knowing all the fine details, but I would suspect by using
mockReturnValueOnce
https://jestjs.io/docs/mock-function-api#mockfnmockreturnvalueoncevalue possibly in combination with
jest.spyOn
there you can setup various values when called nth times
👀 1
d
There's money to be made if someone comes up with some training material around this. I'd love to implement JEST, but I'd like to see it in practical use .. not super simply and unrealistic examples.
1000 1
👀 4
d
also worth mentioning, there's a PR out for some of the remaining modules (including
runtime
etc., before remaking your own) https://github.com/oracle/netsuite-suitecloud-sdk/pull/644
❤️ 1
e
Some day @darrenhillconsulting, some day ....
🙏 2
🙏🏻 1
s
NFT has some 'real world' unit tests that have been in place for years now.
w
@Shawn Talbert Bored Apes again? awkward looking monkey puppet animated
s
No idea what that means.
w
s
Meh, our NFT existed long before the buzzword above.
e
Been a while, but in case anyone sees this and gets curious, here is how I ended up solving this without the
suitecloud-unit-testing-stubs
module; I've put the latter through its paces at work and it gets even easier with that in place
👍 1