我有这个gulp
任务:
gulp.task('test', function () {
return gulp.src('test/runner.html')
.pipe(mochaPhantomJS());
});
这是我的runner.html
:
<!DOCTYPE html>
<html>
<head>
<title>Mocha</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="../node_modules/mocha/mocha.css" />
</head>
<body>
<script src="../node_modules/mocha/mocha.js"></script>
<script>mocha.setup('bdd')</script>
<script src="../node_modules/chai/chai.js"></script>
<script src="../node_modules/requirejs/require.js"></script>
<script>
var assert = chai.assert;
var expect = chai.expect;
var should = chai.should();
</script>
<script src="spec/test.js"></script>
<script>
if (window.mochaPhantomJS) {
console.log('Running mochaPhantomJS...');
mochaPhantomJS.run();
} else {
console.log('Running mocha...');
mocha.run();
}
</script>
</body>
</html>
这是我的test.js
文件:
var chrome = require('sinon-chrome');
var popup = require('../../source/scripts/popup');
describe('sumit', function(){
before(function () {
global.chrome = chrome;
});
it('Should return 1', function(){
assert(popup.sum(0,1) === 1);
});
})
但是当我运行时,gulp test
我收到此错误消息:
错误:尚未为上下文加载模块名称“sinon-chrome”:_。使用要求([])
http://requirejs.org/docs/errors.html#notloaded
在 file:///c:/dev/extensions/NEW_EXPRESS/node_modules/requirejs/require.js:1 的 defaultOnError 在 file:///c:/dev/extensions/NEW_EXPRESS/node_modules/requirejs/require.js 的 onError :547 in localRequire 在 file:///c:/dev/extensions/NEW_EXPRESS/node_modules/requirejs/require.js:1433 在 requirejs 在 file:///c:/dev/extensions/NEW_EXPRESS/node_modules/requirejs/require .js:1794