I am trying to start using the `netsuite-suiteclou...
# suitescript
s
I am trying to start using the
netsuite-suitecloud-sdk
and I am running into an issue when unit testing that it can't find N/log. Has anyone encountered this and figured out a way to get around it?
d
I assume there are multiple ways, but personally I used
setupFiles
property in jest.config.js https://jestjs.io/docs/configuration#setupfiles-array
s
Ok, I think i'll take a look at it. Do you have an example for where you got all of your mocks from by any chance?
d
inside of my configured setup file I then added something to the effect of:
Copy code
global.log = {
	debug     : (options) => null,
	audit     : (options) => null,
	emergency : (options) => null,
	error     : (options) => null,
};
if that is what you mean, I did similarly with util & other globally available NS module methods so that they were available to jest (probably could be done better with some variation of mocks instead, though this was just how I setup at the time to get around)
s
Thanks! I'm trying to make myself do unit testing and quit saying I'll learn it later lol. facepalm
❤️ 1
d
yah there's definitely a bit of a learning curve at first I would say, but definitely worthwhile in the end. sometimes a bit challenging to get how the NetSuite Unit Testing is setup to behave, but at the end of the day have enjoyed working with jest framework a lot and got it to do everything I wanted so far