Merge branch 'master' of https://github.com/HBehrens/grunt-contrib-jasmine into HBehrens-master
* 'master' of https://github.com/HBehrens/grunt-contrib-jasmine: use fixed version of grunt-lib-phantomjs to update https://github.com/gruntjs/grunt-contrib-jasmine/pull/44 test to verify hanging on failed load of iframe Conflicts: package.json
This commit is contained in:
commit
c8241cd172
28
Gruntfile.js
28
Gruntfile.js
@ -9,7 +9,22 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = function(grunt) {
|
||||
|
||||
grunt.initConfig({
|
||||
|
||||
connect: {
|
||||
return500: {
|
||||
options: {
|
||||
port: 9000,
|
||||
middleware: function(connect, options) {
|
||||
return [function(req, res, next){
|
||||
res.statusCode = 500;
|
||||
res.end();
|
||||
}];
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
jshint: {
|
||||
all: [
|
||||
'Gruntfile.js',
|
||||
@ -80,8 +95,16 @@ module.exports = function(grunt) {
|
||||
consolidate: true
|
||||
}
|
||||
}
|
||||
},
|
||||
selfTest: {
|
||||
options: {
|
||||
specs:["test/selfTest/*.js"],
|
||||
"--web-security": "no"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
nodeunit: {
|
||||
tasks: ['test/*_test.js']
|
||||
}
|
||||
@ -92,7 +115,8 @@ module.exports = function(grunt) {
|
||||
grunt.loadNpmTasks('grunt-contrib-jshint');
|
||||
grunt.loadNpmTasks('grunt-contrib-nodeunit');
|
||||
grunt.loadNpmTasks('grunt-contrib-internal');
|
||||
grunt.loadNpmTasks('grunt-contrib-connect');
|
||||
|
||||
grunt.registerTask('test', ['jshint', 'jasmine', 'nodeunit']);
|
||||
grunt.registerTask('default', ['test', 'build-contrib']);
|
||||
grunt.registerTask('test', ['connect:return500', 'jasmine', 'nodeunit']);
|
||||
grunt.registerTask('default', ['jshint', 'test', 'build-contrib']);
|
||||
};
|
||||
|
@ -28,14 +28,15 @@
|
||||
"test": "grunt test"
|
||||
},
|
||||
"dependencies": {
|
||||
"grunt-lib-phantomjs": "~0.3.0",
|
||||
"grunt-lib-phantomjs": "~0.4.0",
|
||||
"rimraf": "~2.1.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"grunt-contrib-internal": "~0.4.5",
|
||||
"grunt-contrib-nodeunit": "~0.2.0",
|
||||
"grunt-contrib-jshint": "~0.6.2",
|
||||
"grunt": "~0.4.0"
|
||||
"grunt": "~0.4.1",
|
||||
"grunt-contrib-connect": "~0.4.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"grunt": "~0.4.0"
|
||||
|
32
test/selfTest/TaskSpec.js
Normal file
32
test/selfTest/TaskSpec.js
Normal file
@ -0,0 +1,32 @@
|
||||
describe("Task", function() {
|
||||
|
||||
/*
|
||||
when running this test with `grunt jasmine:selfTest -d` you got this output
|
||||
|
||||
[D] ["phantomjs","onLoadFinished","success"]
|
||||
[D] ["phantomjs","onResourceRequested","http://httpbin.org/status/500"]
|
||||
[D] ["phantomjs","onResourceReceived","http://httpbin.org/status/500"]
|
||||
[D] ["phantomjs","onLoadFinished","fail"]
|
||||
[D] ["phantomjs","fail.load","_SpecRunner.html"]
|
||||
|
||||
phantomjs.page.onLoadFinished seems to be called for iframes, too.
|
||||
A failing onLoadFinished caused this grunt taks to hang.
|
||||
Now, after removing the event handler, this following test should work as expected
|
||||
*/
|
||||
it("can handle fail on iframe", function(){
|
||||
var waitedLongEnough;
|
||||
runs(function(){
|
||||
iframe = document.createElement("iframe");
|
||||
iframe.src = "http://localhost:9000";
|
||||
document.body.appendChild(iframe);
|
||||
|
||||
setTimeout(function(){waitedLongEnough=true;}, 50);
|
||||
});
|
||||
waitsFor(function(){
|
||||
return waitedLongEnough;
|
||||
});
|
||||
runs(function(){
|
||||
expect(true).toBeTruthy("without change in grunt-lib-phantomjs, jasmine would never reach this line");
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user