-
Notifications
You must be signed in to change notification settings - Fork 102
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Testing useWorker #41
Comments
Perfect analysis @gonzachr thanks! 👏 I like the first option (karma approach), since it's based on a headless browser, moreover |
Awesome @alewin! I'll open a PR later today 👍 |
Admittedly at first I just tried the first preprocessing option I found. Today I will make a few experiments with rollup as I found another karma preprocessor compatible with it. I heard good things about rollup specially for libraries so I think is a nice option, becase it really feels a bit bloated to add Webpack just for testing. Specially having such a compact bundler for the project itself 😅 |
Closing after #88 |
Since they are plans to add new features (#36) I started to work in adding some tests for the hook. I initially setup Jest with react-hooks-testing-library. But found that Jest (which uses jsdom) does not have an implementation for URL.createObjectURL nor Web Workers.
So I had to dig a bit on the internet 🌈to find potential workarounds, and it seems that they're two approaches to test workers (afaik) that we can use.
Options
URL.createObjectURL
mock :).Imo, I prefer karma since it will provide reliable behavior for the tests. What do you guys think? 😄
For reference, this is the test I tried with Karma:
The text was updated successfully, but these errors were encountered: