Limit DOM/HTML dump in UI Unit Test logs to improve readability

I am looking for a solution to prevent the full DOM/HTML tree from being dumped into the console when a UI Unit Test fails. Currently, these logs take up a lot of space and are very difficult to read, especially when components contain large SVG data or HTML structures.

Instead of a massive dump, it would be much better to see a concise error report so we can quickly identify which tests failed. If all information will be needed, flag to show always will be used.

IIRC the tree is not printed by default. Can you please provide additional information about your test class?

@ActiveProfiles(“uiunit”)
@SpringBootTest(classes = {Application.class})
@TestExecutionListeners({
VaadinScopeTestExecutionListener.class,
DependencyInjectionTestExecutionListener.class,
WithSecurityContextTestExecutionListener.class
}) With extend SpringUiUnitTest

OK, now I see. The UI snapshot is in the message of the IllegalStateException thrown by the ensureVisible() check.
So, no, currently you cannot suppress this message unless your test specifically catches the exception (e.g., with assertThrows(...)).
I don’t remember right now if there’s some JUnit extension point that can be implemented (maybe TestExecutionExceptionHandler?)

I will check to see if this is an option. Thanks

This dump is crucial to find the problem. I don’t see why it shouldn’t be printed

When running our suite of approximately 300 tests, if 5 to 10 tests fail, the console output becomes often overwhelmed by massive DOM dumps. This makes it very difficult to quickly identify which specific tests failed.

Ideally, the console should only show a concise list of failed tests. All detailed information, such as the DOM tree and stack traces, will be redirected to a log file.

Try this

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
        <redirectTestOutputToFile>true</redirectTestOutputToFile>
    </configuration>
</plugin>

redirectTestOutputToFile=true sends all System.out and System.err output from tests to the files in target/surefire-reports/ instead of the console.
The test results summary (how many passed/failed) still shows on the console – only the test output is redirected.​​​​​​​​​​​​​​​​