Is it possible to run only one specific test in CasperJS? -
i need similar mocha's only method
it.only "should test something" for doesn't know means mocha launch 1 test among tests launched if wouldn't write only
is possible similar in casperjs? i'm using annoying "comment/uncomment" technique
you utilize argument alternative : casperjs test scriptname.js --only=true
and in casperjs file :
class="lang-js prettyprint-override">if (casper.cli.get("only")){var only=true;} else {var only=false;} and before wanted assertion :
class="lang-js prettyprint-override">if (!only){ test.assertexists(....);} else {"should test something"} you can reverse in similar way.
edit :
if it's scenario utilize casperjs setup() function , phone call function() filters scenarios, using command alternative , casper.test.done(), :
var setlevel = function(level){ if(casper.cli.get("mode") !== level){ casper.test.done(); } }; casper.test.begin('\n***** scenario : *****',{ setup: function(test) { setlevel("only"); }, test: function(test){ "use strict"; casper.start() .run(function() { this.test.comment('--- done ---\n'); test.done(); }); } }); so if phone call casperjs test path/to/folder --mode="only", instantly close every scenario level isn't set only. output opening logs though, if don't want see them, utilize casper.test.setup() method before casper.test.begin(). yes it's unusual finish test before calling begin() if remember works.
it's ugly hack, me it's solution. problem : it's necessary utilize setup() , setlevel() in every files. there isn't native alternative anyway.
casperjs
No comments:
Post a Comment