title: How do you properly split up casperjs tests with a shared browser instance
body: <p>I'm trying to test different parts of a "mostly" single page application.  I'd like to split the tests up, but I really only want to load the page once and then have the tests go through and click the links etc.</p>
  
  <p>Here's my code:</p>
  
  <p>PRE.js</p>
  
  <pre><code>var port = require('system').env.PORT
  var tester;
  
  casper.options.viewportSize = {width: 1024, height: 768};
  
  casper.test.begin('Test login', function suite(test) {
      var done = false;
      casper.on("page.error", function(msg, trace) {
          this.echo("Error:    " + msg, "ERROR");
          this.echo("file:     " + trace[0].file, "WARNING");
          this.echo("line:     " + trace[0].line, "WARNING");
          this.echo("function: " + trace[0]["function"], "WARNING");
      });
  
      casper.on('remote.message', function(message) {
          this.echo('remote message caught: ' + message);
          if (message == "done") { 
              done = true;
          }
      });
  
      casper.start('http://localhost:' + port, function() {
  
      // Verify that the main menu links are present.
          test.assertExists('input[name=username]');
          // 10 articles should be listed.
          test.assertElementCount('input', 3);
          casper.fill("form", {
              "username": "username",
              "password": "my password goes right here you cant have it"
          }, true);
          casper.then(function() {
                  casper.waitFor(function(){
                      return done;
                      }, function(){
                      tester = casper.evaluate(function(){
                          return tester;
                      });
                      test.assert("undefined" != typeof tester);
                      test.assert(Object.keys(tester).length &gt; 0);
                  });
          });
      });
  
      casper.run(function() {
          test.done();
      });
  });
  </code></pre>
  
  <p>and then I have a second file (and there will be lots more like this):
  TEST.js</p>
  
  <pre><code>casper.test.assert(true);
  
  casper.capture('.screenshot.png');
  casper.test.done();
  </code></pre>
  
  <p>I'm hoping to get a screenshot of the browser session from pre.js.</p>
  
  <p>I run it from a specialized program that starts up my program, but in essence it runs:</p>
  
  <pre><code>casperjs test casper_tests --pre=pre.js
  </code></pre>
  
  <p>casper_tests holds both files above</p>
  
  <p>My Question:</p>
  
  <p>What's the right way to do this?  No screenshot is being taken, and perhaps more important (though I haven't tried it yet) I want to be able to click things inside and verify that other pieces are working.  The screenshot just verifies that i'm in the right neighborhood.</p>