-
-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Define a proper way to mock imports #262
Comments
default exports is probably the right way to do it. I'm struggling with similar issue myself on another project, I'll be happy to hear what you come up with. btw, object mutation isn't cheating - at least not in this context. That's essentially what |
I've tested solutions in sandbox (code):
Personally I'd prefer "jest". There are not so many tests right now, but there are plans to write a lot of them (jsdelivr/globalping-probe#101). So having a framework instead of a list of libraries will help us to write them faster. We can try to migrate a few most hard test suits to see how much effort that requires. @MartinKolarik @patrykcieszkowski maybe you have any thoughts? |
I personally like the setup built with swappable libraries, over having to rely on a framework. As for the custom loader - we've switched to Correct me if I'm wrong, but I don't think neither |
I'm not strongly against jest but also not particularly in favor. The combination of libraries we already have (+ the es mocking) has roughly the same features, and we use it consistently across all projects. As for the loader, we can definitely change it (see #180). |
I've tested |
@alexey-yarmosh Can this be closed? |
Yes. |
Currently we are unable to mock our own modules and npm modules. That is so because we are using ES modules and seems that there are no out-of-the-box solution for the TS+ES modules combination. For that reason we are not able to unit test some of our modules.
At the end we should come to the solution that will be able to mock imports both of our own and npm dependencies of any kind. Without cheats like DI, mutation of the existing object, or things like
export default {func1, func2, func3}
.Possible options:
The text was updated successfully, but these errors were encountered: