【发布时间】:2015-02-14 05:07:33
【问题描述】:
我遇到了问题,甚至不确定从哪里开始故障排除。
我正在使用slightly modified mocha-casperjs。 CasperJS 是 PhantomJS 的包装器。我正在尝试在完成测试时集成 Growl 通知。
我可以在调用 mocha.run 之前成功执行通知,如下所示:
execFile("terminal-notifier", ["-message", "Tests Begin"], null, function (err, stdout, stderr) {
console.log("execFileSTDOUT:", JSON.stringify(stdout))
console.log("execFileSTDERR:", JSON.stringify(stderr))
})
// for convience, expose the current runner on the mocha global
mocha.runner = mocha.run(function() {
...
但是,这失败了:
// for convience, expose the current runner on the mocha global
mocha.runner = mocha.run(function() {
execFile("terminal-notifier", ["-message", "Tests Begin"], null, function (err, stdout, stderr) {
console.log("execFileSTDOUT:", JSON.stringify(stdout))
console.log("execFileSTDERR:", JSON.stringify(stderr))
})
...
我不太了解 Mocha 或 PhantomJS 的内容。 Mocha 是否会吃掉标准输出或类似的东西,导致 execFile 调用失败?还有什么我没有得到的吗?
谢谢, 凯文
--- 更新 ---
情节变厚了。只包含 casper 对象就会杀死 execFile。
使用“casperjs test.js”运行以下代码成功输出 execFile。取消注释 casper 对象不会导致任何输出。
'use strict';
var process = require("child_process");
var spawn = process.spawn;
var execFile = process.execFile;
execFile("ls", ["-lF", "/usr"], null, function (err, stdout, stderr) {
console.log("execFileSTDOUT:", JSON.stringify(stdout));
console.log("execFileSTDERR:", JSON.stringify(stderr));
});
//var casper = require('casper').create();
//casper.exit();
【问题讨论】:
-
它是如何失败的?您收到错误消息吗?例外?它只是不执行?
-
据我所知,什么都没有。没有错误,也没有例外。回调永远不会被调用。
标签: phantomjs mocha.js execfile