title: How to modularize CasperJS test steps?
body: <p>I am pretty new to CasperJS and I have started creating a test suite. Some of the steps (like logging in to the application) will be reused a lot, so we would like to manage them in library files (which are included in the test files). </p>
  
  <p>Plus, we have multiple environments running (dev, integration, production etc.) so we need to parametrize the test steps for this, so it shall be possible to pass parameters to the modules.</p>
  
  <p>I searched the documentation and stackoverflow (I am aware there are similar questions), but my Javascript skills are too limited obviously and I was not able to get this up and running. </p>
  
  <p>This is my example test file:</p>
  
  <pre><code>// googletesting.js
  casper.test.begin('Google search retrieves 10 or more results', 5, function suite(test) {
      casper.start("http://www.google.fr/", function() {
          test.assertTitle("Google", "google homepage title is the one expected");
          test.assertExists('form[action="/search"]', "main form is found");
          this.fill('form[action="/search"]', {
              q: "casperjs"
          }, true);
      });
  
      casper.then(function() {
          test.assertTitle("casperjs - Recherche Google", "google title is ok");
          test.assertUrlMatch(/q=casperjs/, "search term has been submitted");
          test.assertEval(function() {
              return __utils__.findAll("h3.r").length &gt;= 10;
          }, "google search for \"casperjs\" retrieves 10 or more results");
      });
  
      casper.run(function() {
          test.done();
      });
  }); 
  </code></pre>
  
  <p>And this is how it should be like (or similar):</p>
  
  <pre><code>// googletesting2.js
  casper.test.begin('Google search retrieves 10 or more results', 5, function suite(test) {
  
      doGoogleSearch('casperjs'); // pass a search term
      doChecks();
  
      casper.run(function() {
          test.done();
      });
  }); 
  </code></pre>