Skip to content

Mocking Javascript interaction with the DOM #1137

Answered by egil
thatstatsguy asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @thatstatsguy, good question!

A few points:

  1. If Blazor is the owner of a specific part of markup, e.g. it was rendered by Blazor, you probably don't want to change it directly via JavaScript, since that can cause problems for the Blazor renderer. If it is markup not from Blazor you are modifying, then it is obviously not a problem.
  2. The strategy we recommend is that you verify that the call to your JavaScript has happened when you test the component that should perform that call. Treat it as a unit test where you are mocking a web service call.
  3. Then decide if you need to test the JavaScript code. If it is complex, then you can do so in isolation via normal JavaScritp testing methods, or…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@thatstatsguy
Comment options

Answer selected by thatstatsguy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants