Mats Bryntse
13 December 2012

Siesta: Speeding up tests launched inside your IDE

At Bryntum we strongly believe in running our tests frequently. Doing so allows us to rapidly develop and debug tests […]

At Bryntum we strongly believe in running our tests frequently. Doing so allows us to rapidly develop and debug tests without involving a real browser. As mentioned in previous posts, we use the awesome PhantomJS for this since it is really really fast. Since we don’t care at all about the Siesta UI for tests launched from the command line, we can use a simpler version of the HTML harness file. The default harness usually looks like below:

<!DOCTYPE HTML> 
<html>
    <head>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" >
        <meta http-equiv="content-type" content="text/html; charset=UTF-8">

        <link rel="stylesheet" type="text/css" href="../../extjs-4.1.1/resources/css/ext-all.css">
        <link rel="stylesheet" type="text/css" href="node_modules/siesta/resources/css/siesta-all.css">

        <script type="text/javascript" src="../../extjs-4.1.1/ext-all.js"></script>

        <script type="text/javascript" src="node_modules/siesta/siesta-all.js"></script>
        <script type="text/javascript" src="lib/Bryntum/Test.js"></script>

        <script type="text/javascript" src="index.js"></script>
    </head>

    <body>
    </body>
</html>

As you can see, it is loading the full Ext JS library which includes a 240 KB CSS file and a 1.3 MB JS file. This slows down the test start and consumes unnecessary memory. For our in-IDE testing we instead use this ‘index-no-ui.html‘ HTML harness file:

<!DOCTYPE HTML> 
<html>
    <head>
        <script type="text/javascript" src="node_modules/siesta/siesta-all.js"></script>
        <script type="text/javascript" src="lib/Bryntum/Test.js"></script>

        <script type="text/javascript" src="index.js"></script>
    </head>

    <body></body>
</html>

This is the absolute minimum for us to be able to run a test on the command line. Hopefully you can use the same trick to save a second or too each time you want to run a single test in your IDE. This trick is applicable any time you are running automated tests that should not involve the Siesta UI.

Happy testing!

Mats Bryntse

Uncategorized