1
我可以在瀏覽器中異步加載摩卡模塊嗎?我可以肯定地用柴做。是否有任何解決方法使摩卡工作在類似amd的風格中?異步運行mochajs(類AMD)
require.config({
baseUrl: "/scripts",
paths: {
"mocha": "framework/mocha",
"chai": "framework/chai",
"first": "custom/first"
}
});
require(['first', 'mocha', 'chai'], function (first, mocha, chai) {
first.echo();
console.log('something');
console.log('something');
mocha.ui('tdd');
var assert = chai.assert;
suite('"Home" Page Tests', function() {
test('page should contain link to contact page', function() {
assert($('a[href="/contact"]').length);
});
});
mocha.run();
console.log('whatever');
});
以上
first
和
chai
工作精細的代碼示例中
,而mocha
是未定義的。