Javascript integration #851
-
Hi! We are dependent on a 3rd party library and have some functionality we would like under unit test that duo the 3rd party requires javascript to be run. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
Hey @MichaelFack1 this is currently not possible. But you can emulate all the events with bUnit: https://bunit.dev/docs/test-doubles/emulating-ijsruntime.html There are some ideas around making this work but nothing you could use right now. |
Beta Was this translation helpful? Give feedback.
-
As @linkdotnet says, it's not possible and will probably not every be, since that would require us to run a full JavaScript/browser runtime as well, and in that case you might as well just use Playwright or Selenium.
Is that 3rd party lib a JavaScript lib or a Blazor lib? If it's the first, we recommend setting up the JSInterop in bUnir to emulate the responses from the JS lib. Some also wrote their own JS wrapper around 3rd party js libs, so they have a stable facade to call. That will make upgrades to the 3rd party lib more safe, and aligns with the rule of thumb to never mock things you dont own. Hope this helps. |
Beta Was this translation helpful? Give feedback.
As @linkdotnet says, it's not possible and will probably not every be, since that would require us to run a full JavaScript/browser runtime as well, and in that case you might as well just use Playwright or Selenium.
Is that 3rd party lib a JavaScript lib or a Blazor lib?
If it's the first, we recommend setting up the JSInterop in bUnir to emulate the responses from the JS lib. Some also wrote their own JS wrapper around 3rd party js libs, so they have a stable facade to call. That will make upgrades to the 3rd party lib more safe, and a…