Replies: 1 comment
-
https://github.com/tmikov/hermes-jsi-demos/tree/master/hf-runner |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Problem
I'm writing a native module using the JSI interface and I'd like to have a headless runner for hermes to run my tests against my native code. The pattern that I typically see people do is build a full blown react native application to run their test suite in. It's not really a pleasant experience to say the least, it's also quite slow..
At the moment we use https://github.com/ExodusMovement/test to run our "plain" JavaScript tests with the
hermes
binary shipped inhermes-engine-cli
package. It takes a bit of mocking to make everything run but at least it's fast enough.At first I thought the JSI is more a react native thing but there is an experimental runtime wrapper for the JSI in the ABI folder so it seems to be on track to become a first class citizen?
hermes/API/hermes_abi/HermesABIRuntimeWrapper.cpp
Line 122 in 038bfdb
JSI missed his older brother N-API, so he also came around the corner, developers from the NodeJS ecosystem may want to test their code across multiple JS engines.
Perhaps we can have a solution that works for both?
Solution
Solution 1: Write your own runtime
Slap some extra code on to this and build your own runtime:
https://github.com/facebook/hermes/blob/main/tools/jsi/jsi.cpp#L101-L111
Solution 2: dynamically hook functions in the binary
Another solution could be to use
LD_PRELOAD
/DYLD_INSERT_LIBRARIES
and intercept some function like:hermes/lib/VM/Runtime.cpp
Line 1699 in 038bfdb
Then call it using
dlsym
, and afterwards do our own thing to .Seems very hacky, but also quite versatile at the same time.
Solution 3: ???
Happy to explore any solutions from the comments.
Beta Was this translation helpful? Give feedback.
All reactions