Get help with testing, discuss unit testing strategies etc.


Post by AaronTovo »

What's the best way to clear the iframe?

I need to load my entire app in order to get certain dependencies (the localized strings) but that causes the whole app to render in the iframe. In order to test smaller components I would like to clear the iframe so that I can display the components I'm testing.

Post by mats »

You should create separate test for each component (or aspect or a larger component) that you're testing. No need to ever manually touch/modify the iframe, let Siesta handle all that :)

Post by AaronTovo »

I'm only testing one component. The problem is that I need to load the app to get the localized strings that are used by that component. Those strings are served up via a jsp file that uses spring. See https://forum.bryntum.com/viewtopic.php?f=20&t=2033

If I don't have those strings, then the references to those string yield 'undefined' errors.

And of course when I load the app it renders in the iframe. If there is a way to load the jsp page without displaying it, then that would be good enough.

Post by nickolay »

Can you serve those localization strings as the separate jsp file? So instead of
        <script type="text/javascript">
            TR = {
                AccessionEmptyText: '<spring:message code="home.AccessionEmptyText" javaScriptEscape="true"/>',
            }
        </script>
you can do:
        <script type="text/javascript" src="path/to/localization_script.js"></script>
And in this way you can just include "path/to/localization_script.js" to your preloads.

Post by AaronTovo »

Hi Nickolay,

I've tried something similar to that. JSP has a construct called a 'JSP Fragment', a .jspf file, that I can create and it contains only the TR definition
        <script type="text/javascript">
            TR = {
                AccessionEmptyText: '<spring:message code="home.AccessionEmptyText" javaScriptEscape="true"/>',
            }
        </script>
A fragment can be included in multiple jsp files with a line that looks like
<%@include file="myFragmentFile.jspf" %>
.

So I include it in my app's jsp file and also in a new jsp file called tr.jsp. Then I set the hostPageUrl for my test to load tr.jsp and I get the strings I need. This works, though it seems like a bit of a backdoor use of hostPageUrl.

Post Reply