Created
June 14, 2012 11:40
-
-
Save danpalmer/2929799 to your computer and use it in GitHub Desktop.
Casperjs Multiple Tests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Test 1 | |
casper.start(); | |
casper.open('http://localhost:3000/'); | |
casper.then(function() { | |
// asserts | |
}); | |
casper.run(function() { | |
// I can't mark as done here because the first test to finish will be used? | |
}); | |
// | |
// Not sure how best to do this, can I put the whole of each test inside the start function and reference this? | |
// | |
// Test 2 | |
casper.start(); | |
casper.open('http://localhost:3000/'); | |
casper.then(function() { | |
// asserts | |
}); | |
casper.run(function() { | |
this.test.done(); | |
}); |
Thanks for the reply, but does thenOpen
keep the browser state? I ask because I need cookies to be reset and the only way I can find to make this happen is to have totally separate testing processes with their own start
.
Hmm. Try with the clear()
method, I think it also resets cookies as a side effect.
Otherwise, split your tests across two files and run the suite using $ casper test
:)
Ok, thanks for the tip, I didn't know about clear()
. For the moment I'm running everything as a suite with casper test
.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's how I'd do it: