我按照这里描述的编程方式使用Mocha:
https://github.com/visionmedia/mocha/wiki/Using-mocha-programmatically
与示例的编写方式非常相似:
测试runner.js:
var Mocha = require('mocha');
var mocha = new Mocha();
mocha.addFile('spec.js');
mocha.run(function() {});
Run Code Online (Sandbox Code Playgroud)
在测试规范中,我正在启动无头浏览器以在特定URL上运行测试:
spec.js:
var Browser = new Browser();
browser.visit(url, function(){});
Run Code Online (Sandbox Code Playgroud)
有没有办法将所需的url从test-runner.js传递给spec.js?