importing instance for jest mock
I wanted to do something like
to mock my modules to return the correct value. The import syntax returns a promise and a unknown type which isn't ideal. Is there a better way other than directly indexing from the data model to mock the module script?
Solution:Jump to solution
Gist
jest roblox-ts testing utils
jest roblox-ts testing utils. GitHub Gist: instantly share code, notes, and snippets.
17 Replies
bump
i don't think there's any better way to do it
ig you could mock the services itself
I tried using $getModuleTree
yea thats how u do it
does that work for file specific modules
like in my case, LocalPlayer
yea those functions are from my testing utils
can you send me it
š
sure lol wait
thx
Solution
Gist
jest roblox-ts testing utils
jest roblox-ts testing utils. GitHub Gist: instantly share code, notes, and snippets.
haven't tested the usage stuff yet but something like that should work
oh yeah i also mock the ts runtime just incase of any weird errors although im not really sure if it does anything or not
hmmm
could be useful if u wanna mock the internals like generators n stuff
thanks
jest is so good
it really is
mocking
alr i'll mark this as solved
actually you might need the runtime files aswell
lmk when you need it cus i gtg rn