Note that there are some explanatory texts on larger screens.

plurals
  1. PODisabling LocalStorage on PhantomJS for clean testing?
    primarykey
    data
    text
    <p>Just started working with CasperJS a few days ago.</p> <p>I create a script today to test how LocalStorage behaves and if I could disable it because that's necessary in order to keep tests from affecting each other.</p> <p><strong>Background</strong></p> <p>I'm working on a Backbone wizard that ask for a value on the first page. When you click the Continue button, it saves the value to LocalStorage then displays it on the second page.</p> <p>I'm using <code>casperjs test &lt;script.js&gt;</code> both with and without <code>--local-storage-quota=0</code>.</p> <p><strong>First Attempt</strong></p> <p>Wrote a CasperJS script that does the following:</p> <ol> <li>load Page</li> <li>check the contents of the model (empty, as it should be)</li> <li>click Continue</li> <li>check the contents of the model after Page 2 loads (contains the value, as it should)</li> <li>open Page 2 directly as a new page using casper.thenOpen()</li> <li>check the contents of the model after Page 2 loads</li> </ol> <p>If LocalStorage is enabled, step 6 should have the same result as step 4 (value exists in model).</p> <p>If LocalStorage is disabled, step 6 should have the same result as step 2 (model is empty).</p> <p>Everytime I ran the script, I determined that LocalStorage was enabled. The '--local-storage-quota=0' parameter made no difference.</p> <p><strong>Second Attempt</strong></p> <p>At that point, I decided to determine if the LocalStorage was attached to a specific Casper instance. If so, then I could work around this by creating a new Casper instance for every test, thereby starting with a clean slate.</p> <pre><code>var Casper = require( 'casper' ); casper = Casper.create(); casper.test.begin( 'test for Local Storage, part 1', 0, function suite (test) { ... }); casper = Casper.create(); casper.test.begin( 'test for Local Storage, part 2', 0, function suite (test) { ... }); </code></pre> <p>However, the second test suite never runs. I don't know if Casper wasn't intended to have multiple instances made in the same script, or if I'm just organizing it incorrectly.</p> <p><strong>Addendum</strong></p> <p>I should add that all test suites end with the following step in case it's relevant:</p> <pre><code>casper.run( function () { test.done(); casper.exit(); }); </code></pre> <p>The docs only specify that test.done() is required. However, my test scripts would hang forever until I added the call to casper.exit().</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload