Closed dschinkel closed 8 years ago
There is 0 node.js code in mocha-phantomjs
. It runs in casper which runs in phantomjs. it is not node.js. don't run it in node. Just exect the process. Something like:
gulp.task('mocha-acceptance', function() {
process.env.PORT = 8000;
return gulp.src([config.test.src.acceptance], { read: false })
.pipe(exec('**mocha-casperjs test/features/specs/*-spec.js**'))
});
tried that and get:
Error in plugin 'gulp-exec'
Message:
Command failed: /bin/sh -c mocha-casperjs test/features/specs/*-spec.js
Details:
killed: false
code: 1
signal: null
cmd: /bin/sh -c mocha-casperjs test/features/specs/*-spec.js
ran it a second time and got
Message:
Command failed: /bin/sh -c **mocha-casperjs test/features/specs/*-spec.js**
/bin/sh: **mocha-casperjs: command not found
Details:
killed: false
code: 127
signal: null
cmd: /bin/sh -c **mocha-casperjs test/features/specs/*-spec.js**
I tried to then for troubleshooting run /bin/sh -c mocha-casperjs test/features/specs/*-spec.js
in the console and it seemed to run ok...why would it be failing from Gulp?
Also I'm wondering why you're referring to mocha-phantomjs and wondered what you referring to as in "don't run it in node, it's not node.js". What was I trying to run in node and why not ? Trying to understand more than is inferred here by your sentence, can you be more detailed?
I decided to try gulp-shell and had better luck
.pipe(shell(['mocha-casperjs test/features/specs/*-spec.js']))
all good now!
I'm struggling to figure out how I'd setup a gulp task to run this for me essentially:
mocha-casperjs test/features/specs/*-spec.js
I want it as a gulp task for obvious reasons, automation:
1) so I can run it on watch of my js file changes 2) I don't want to run it until the server has started and I've bundled files or on watch, I've re-bundled files. Instead I want my mocha-casper tests to run after bundling or start of server + bundling.
I've tried this in my gulpfile:
but then now, my tests bomb saying they no longer can resolve my casper object in my spec file:
viewing-companies-spec.js (just part of my code, but shows you how I'm using the casper object)
Error in console:
The above tests run green when I run it as an npm script straight from the command-line manually, but I want to run it as a gulp task now instead.