0
我有gulp-jasmine-phantom
正在运行,但我得到了一个ReferenceError: Tictactoe is not defined
。我有感觉我犯了一些根本性的错误。如何用gulp-jasmine,gulp-jasmine-browser或gulp-jasmine-phantom测试我的功能?
我的文件结构:
gulpfile.js
spec/test.js
source/js/tictactoe.js
代码的简化版本:
吞:
gulp.task('site:js:test', function() {
return gulp.src('spec/test.js')
.pipe(jasmine())});
test.js:
require("../source/js/tictactoe");
describe("Tictactoe", function() {
var t = new Tictactoe();
it("expects there to be able to add a mark", function() {
t.addMark([0,0], 1);
expect(t.board[0,0]).toBe(1);
});
});
tictactoe.js
function Tictactoe(size) {
this.size = size;
// default variables:
this.EMPTY = "";
this.board = [];
for (var i = 0; i < this.size; i++) {
this.board[i] = [];
for (var j = 0; j < this.size; j++) {
this.board[i][j] = this.EMPTY;
}
}
}
Tictactoe.prototype.addMark = function(position, player)
{}
我也试过gulp.src(['source/js/tictactoe.js', 'spec/test.js'])
然后没有要求在test.js。也没有成功。我也试过gulp-jasmine
和gulp-jasmine-browser
。你能帮我做到吗?
非常感谢!