Put test1.js
and test2.js
into a tests/
directory, then run the suite:
$ casperjs test tests/ --pre=pre.js --includes=inc.js --post=post.js
Test file: /Users/nperriault/tmp/pre-inc/pre.js
Hey, I'm executed before the suite.
Test file: /Users/nperriault/tmp/pre-inc/tests/test1.js
# this is test 1
Hi, I've been included.
PASS Subject is strictly true
Test file: /Users/nperriault/tmp/pre-inc/tests/test2.js
# this is test 2
Hi, I've been included.
PASS Subject is strictly true
Test file: /Users/nperriault/tmp/pre-inc/post.js
Hey, I'm executed after the suite.
PASS 2 tests executed, 2 passed, 0 failed.
A more colorful output:
Thanks for the sample, guys.
I try to use
--includes
option and it does not act as expected: "will include the foo.js and bar.js files before each test file execution". One only include is performed, beforepre
scripts. Here is the sample code with customizedinc.js
:Echo phrase is shown only once in output: