Mocking Javascript interaction with the DOM #1137
-
Hi all - apologies in advance if this has been asked somewhere else As per this discussion, I'm aware that BUnit doesn't run a JS Runtime. Therefore if you've got a div in your razor component such as
and you've got a Javascript file in your solution which is called to modify the div with something like
you won't be able to use that Javascript file in your testing. Question
then one could say "ignore JS runtime, we'll see how the component behaves with this injected HTML" If something like that isn't possible, my assumption would be that testing this kind of behaviour should rather be done through End to end testing frameworks like Playwright? Many thanks in advance for any and all suggestions! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @thatstatsguy, good question! A few points:
For example, the Blazor team uses Selenium/Playwright because they have very complex interactions between their C# parts and JavaScript/TypeScript parts of the code. In my case, the JavaScript I need to write is just small functions around browser APIs so I've yet to feel the need to do thorough testing of the JavaScript. |
Beta Was this translation helpful? Give feedback.
Hi @thatstatsguy, good question!
A few points: