Created
September 11, 2014 11:51
-
-
Save NewGyu/64ddef2561fdee2b63af to your computer and use it in GitHub Desktop.
spyOn in gulp-jasmine
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var str1 = new String(); | |
var str2 = new String('123aa') | |
describe('example',function() { | |
it('use spy',function(){ | |
spyOn(str1,'indexOf').andCallFake(function(s){ | |
return 50; | |
}); | |
expect(str1.indexOf('aa')).toEqual(50); | |
}); | |
it('unuse spy',function(){ | |
expect(str2.indexOf('aa')).toEqual(3); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var gulp = require('gulp'); | |
var jasmine = require('gulp-jasmine'); | |
gulp.task('test', function(){ | |
gulp.src(['test/**/*Spec.js']) | |
.pipe(jasmine({verbose:true,includeStackTrace:true})); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sindresorhus/gulp-jasmine#26
このissueの報告用の再現ケースであるが、上記で自己レスしたように勘違いだった。
gulp-jasmineは内部でminijasminenode2に依存しており、これは名前が示す通りjasmine2系である。
jasmine2系からspyの書き方が変わっており、
このように書くのが正しい。