Skip to content

Testing Blazor component's css styles #1464

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

You must be logged in to vote

Hey, welcome to the bUnit community.

The short answer is that bUnit does not load your style sheets, so the DOM nodes (provided by the anglesharp library) will not have any knowledge about them.

You could probably look at anglesharp api and load the css files and then be able use ComputeCurrentStyle(), etc., the mainrainer of anglesharp @FlorianRappl will know this.

My suggestion would however be to not focus on css files with bUnit tests. It will not give you a visual verification anyway, so there is little value there. If I wanted to protect against regression in the visuals of components, I would do snapshot testing of my css files, or even better, use playwright to render the componen…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@OClarkMT
Comment options

@egil
Comment options

egil May 10, 2024
Maintainer

Answer selected by OClarkMT
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