nathanboktae / mocha-casperjs

Write CasperJS tests using Mocha
MIT License
120 stars 29 forks source link

reporters with file option doesn't seem to work #45

Closed amirdt22 closed 9 years ago

amirdt22 commented 10 years ago
mocha-casperjs --reporter=spec --file=casper.spec test/casper/users.js

produces the output on the console and creates a casper.spec file that contains some odd bytes:

$ cat casper.spec 
$ ll casper.spec 
-rw-r--r-- 1 adt22 adt22 72 Oct 23 11:41 casper.spec
$ od -bc casper.spec 
0000000 033 133 062 113 033 133 060 107 033 133 062 113 033 133 060 107
        033   [   2   K 033   [   0   G 033   [   2   K 033   [   0   G
*
0000100 033 133 062 113 033 133 060 107
        033   [   2   K 033   [   0   G
0000110

the only reporter I've found that works with the --file option is markdown

for type in `mocha --reporters | sed -e 's/ - .*//g'`; do 
  echo $type; 
  mocha-casperjs --reporter=$type --file=casper.$type test/casper/users.js; 
done

$ ll -tr casper.*
-rw-r--r-- 1 adt22 adt22  4067 Oct 23 11:24 casper.out
-rw-r--r-- 1 adt22 adt22  4675 Oct 23 11:30 casper.md.html
-rw-r--r-- 1 adt22 adt22   114 Oct 23 11:51 casper.dot
-rw-r--r-- 1 adt22 adt22     0 Oct 23 11:51 casper.doc
-rw-r--r-- 1 adt22 adt22    72 Oct 23 11:51 casper.spec
-rw-r--r-- 1 adt22 adt22     0 Oct 23 11:51 casper.json
-rw-r--r-- 1 adt22 adt22  5658 Oct 23 11:51 casper.progress
-rw-r--r-- 1 adt22 adt22  1077 Oct 23 11:51 casper.list
-rw-r--r-- 1 adt22 adt22     0 Oct 23 11:51 casper.tap
-rw-r--r-- 1 adt22 adt22 14031 Oct 23 11:51 casper.landing
-rw-r--r-- 1 adt22 adt22     0 Oct 23 11:51 casper.xunit
-rw-r--r-- 1 adt22 adt22     0 Oct 23 11:51 casper.html-cov
-rw-r--r-- 1 adt22 adt22  4001 Oct 23 11:51 casper.json-cov
-rw-r--r-- 1 adt22 adt22    10 Oct 23 11:51 casper.min
-rw-r--r-- 1 adt22 adt22   151 Oct 23 11:51 casper.json-stream
-rw-r--r-- 1 adt22 adt22  4067 Oct 23 11:52 casper.markdown
-rw-r--r-- 1 adt22 adt22     0 Oct 23 11:52 casper.nyan
nathanboktae commented 10 years ago

Hmm I thought I had this in the README but I don't. --file only works for reporters that use process.stdout.write not console.log. At that point a simple pipe is the same thing as I have a hook to replace process.stdout.write for reporters, but not console.log.