Provide Interface/Fake for the ScriptEngine To Support Unit Testing #426
MF91WorkPS
started this conversation in
Ideas
Replies: 1 comment 3 replies
-
Hi @MF91WorkPS, Thanks for reaching out. We have a couple of questions.
Script engines are mostly self-contained and have no major dependencies – no I/O, no UX, etc. Why would you want to mock one? In fact, ClearScript's original purpose was for test automation 😊 Also, your code refers to Thanks! |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
we often create HostObjects that have methods calling an async method in a background service. We need to inject the ScriptEngine into the constructor to use the Task to Promise conversion via the task.ToPromise() extension method. Example:
Because deployment and testing of our solution is highly automated, we try to cover any code with Unit and Integration Tests to prevent bugs from being rolled out. However, there are no public interfaces for the abstract class ScriptEngine or its implementations (V8ScriptEngine, ...). Also you cannot implement a fake ScriptEngine, because there are some internal dependencies (IUniqueNameManager, ...). This makes testing with common frameworks such as Moq not easy. E. g. this does not work:
Would it be possible to add a public interface for the ScriptEngine or its implementations? Or alternatively provide a fake such as a NullScriptEngine?
Beta Was this translation helpful? Give feedback.
All reactions