more of a jest-specific question, but similar to e...
# suitescript
d
more of a jest-specific question, but similar to example of : https://github.com/oracle/netsuite-suitecloud-sdk/tree/master/packages/unit-testing#suitecloud-unit-testing-examples has anyone done similar when you need to mock multiple difference Record instances within certain test scenario? I have tried just importing
'N/record/instance'
multiple times assigning to different import variable, but it does not seem to be behaving as desired
b
honestly i havent found their testing code good enough to not just write my own
the N/record/instance is a singleton class, so you have the unenviable task of using mockReturnValueOnce
you can also do the equivalent of implementing the function yourself using a mockImplementation
d
@battk so for my use-case I want to mock an overall Fulfillment record, and then the Inventory Detail Subrecord as well (which I am counting on behaving differently for test assertions) - you're saying I can really just use a single Record import?
b
im not saying its sane, but there is only one Record instance
👍 1
theoretically you can make multiple Records by relying on the constructor property
but thats honestly high risk for code you dont control
s
or you could use NFT where unit testing stubs for record instances are just plain objects