Open vlucas opened 10 years ago
Yes I want to enable this. For now you will have to specify all tests individually.
Yikes, this is sort of a deal-breaker. The README implies the behavior is the same as mocha, e.g. I can pass the --recursive
flag and see the same behavior. What's
I'd naively assume if you can handle all tests in a test
directory, you could the same recursively using something like recursive-readdir. Maybe it's not that simple? I might be able to find time to submit a patch if it's relatively straightforward.
Yikes, this is sort of a deal-breaker.
Three workarounds:
require
s all the other tests as you choose.using something like recursive-readdir.
Phantomjs is not Node.js as I've also pointed out in the readme.
Phantomjs is not Node.js as I've also pointed out in the readme.
Thanks, I am just starting to figure that out now. Missed that in the README because I skipped the section with the heading "third party reporters" because that was not what I was looking for.
Use a script that requires all the other tests as you choose.
This seems palatable - is there a way to enumerate all files in a directory using Phantom's API? So I can do a programmatic require()
in a loop without having to explicitly list each and every file. The link in that section of mocha-chaijs readme to PhantomJS's built in modules points to a non-existent wiki page. I don't see anything on this page that might provide such a capability either :/
Looks like this is the URL that should be used in the readme. I'm reading through the fs
module now and I'll post something once I get it working.
This seems to work. in test/index.js
:
const fs = require('fs'); // http://phantomjs.org/api/fs/
/**
* require all files in this directory (does not filter js only!) and
* recursively require any subdirectories.
*/
function requireDir(dir) {
casper.log('require dir ' + dir);
const items = fs.list(dir);
for (var i in items) {
const item = items[i];
//casper.log('i ' + i + ' ' + item);
if ( item === '.' || item === '..' ) continue;
const path = dir + '/' + item;
if ( fs.isDirectory(path) ) {
requireDir(path);
}
else if ( fs.isFile(path) ) {
casper.log('require '+ path);
require(path);
}
}
}
// require all files/ directories under this dir.
// module.dirname is a phantomJS-specific API
requireDir(module.dirname);
It seems something similar could be integrated into cli.js
and triggered on a --recursive
flag?
Yeah that looks fine! Please put up a PR with a simple test too.
Thanks I'll try but I've moved on from this project in part due to #100 and some related phantomjs issues. Will see if I have a chance to throw together a quick PR.
Currently, there is no way for me to run tests in subdirectories, or to even specify a directory to run tests in. I was expecting to be able to do something like
mocha-casperjs tests/mysubdirectory
, but it errors withCasperError: Can't find module [blah blah blah]
.Running tests with the
mocha-casperjs
command by itself just outputs0 passing (0ms)
. This doesn't allow me to organize my test suite at all, and is contrary to the behavior I would expect.I recommend allowing a parameter that would be EITHER a single file to run, OR a directory of files to run.