spitballing about jest mocks

ok. ok. ok. pure spitballing theory here. All the client side source exists in esmodule form (hopefully importing from eachother?) So then it stands to reason that a jest instance could instanciate an actual Game instance as though it were actually an active game session. With something that mocks out a browser standing in for all the browser APIs, "All you'd need to mock" would be the socket connection server calls.
26 Replies
Calego
CalegoOPā€¢3y ago
crazy train thread Authentication might be a hurdle.
Unknown User
Unknown Userā€¢3y ago
Message Not Public
Sign In & Join Server To View
Calego
CalegoOPā€¢3y ago
client/game.js oh i see doesn't export
Unknown User
Unknown Userā€¢3y ago
Message Not Public
Sign In & Join Server To View
Calego
CalegoOPā€¢3y ago
mmm these files don't actually import or export things... wtf
Unknown User
Unknown Userā€¢3y ago
Message Not Public
Sign In & Join Server To View
Calego
CalegoOPā€¢3y ago
You could even mock out update method if you needed to
Unknown User
Unknown Userā€¢3y ago
Message Not Public
Sign In & Join Server To View
Calego
CalegoOPā€¢3y ago
my dist/ directory looks minified
Unknown User
Unknown Userā€¢3y ago
Message Not Public
Sign In & Join Server To View
Calego
CalegoOPā€¢3y ago
test/common/utils/helpers.test.mjs šŸ‘€ so the common is a module in module form
Unknown User
Unknown Userā€¢3y ago
Message Not Public
Sign In & Join Server To View
Calego
CalegoOPā€¢3y ago
but the actual client files must get like 'concatenated' as the build process or something I'm looking in resources/app/ from the foundry installation node version
Unknown User
Unknown Userā€¢3y ago
Message Not Public
Sign In & Join Server To View
cswendrowski
cswendrowskiā€¢3y ago
this file tests our helpers, it does not help with testing
Calego
CalegoOPā€¢3y ago
aye, i was looking to see how it got the method it was testing, which turns out comes from an actual esmodule
cswendrowski
cswendrowskiā€¢3y ago
you could check out test/harness.mjs if it's there common is a module, so we can test it much easier than client code
Unknown User
Unknown Userā€¢3y ago
Message Not Public
Sign In & Join Server To View
Calego
CalegoOPā€¢3y ago
its not the worst idea in the world lol
Unknown User
Unknown Userā€¢3y ago
Message Not Public
Sign In & Join Server To View
Calego
CalegoOPā€¢3y ago
yeah
Unknown User
Unknown Userā€¢3y ago
Message Not Public
Sign In & Join Server To View
Calego
CalegoOPā€¢3y ago
lol I mean what you have is gonna work fine for simple tests oh i just read where you figured this is the server code isntead of client code. damn
Unknown User
Unknown Userā€¢3y ago
Message Not Public
Sign In & Join Server To View
Calego
CalegoOPā€¢3y ago
https://jestjs.io/docs/es6-class-mocks This is what I was hoping was possible, but isn't with the client files not exporting things
Unknown User
Unknown Userā€¢3y ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server