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
。你能幫我做到嗎?
非常感謝!