-
-
Save asabaylus/3059886 to your computer and use it in GitHub Desktop.
/*global module:false*/ | |
module.exports = function(grunt) { | |
// Project configuration. | |
grunt.initConfig({ | |
pkg: '<json:jquery.sessiontimeout.js.jquery.json>', | |
meta: { | |
banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %> - ' + | |
'<%= grunt.template.today("yyyy-mm-dd") %>\n' + | |
'<%= pkg.homepage ? "* " + pkg.homepage + "\n" : "" %>' + | |
'* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' + | |
' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */' | |
}, | |
concat: { | |
dist: { | |
src: ['<banner:meta.banner>', '<file_strip_banner:src/<%= pkg.name %>.js>'], | |
dest: 'dist/<%= pkg.name %>.js' | |
} | |
}, | |
min: { | |
dist: { | |
src: ['<banner:meta.banner>', '<config:concat.dist.dest>'], | |
dest: 'dist/<%= pkg.name %>.min.js' | |
} | |
}, | |
jasmine: { | |
all: ['test/junit.html'], | |
junit: { | |
dest: 'test-results' | |
} | |
}, | |
lint: { | |
files: ['grunt.js', 'src/**/*.js', 'test/**/*.js'] | |
}, | |
watch: { | |
files: '<config:lint.files>', | |
tasks: 'lint qunit' | |
}, | |
jshint: { | |
options: { | |
curly: true, | |
eqeqeq: true, | |
immed: true, | |
latedef: true, | |
newcap: true, | |
noarg: true, | |
sub: true, | |
undef: true, | |
boss: true, | |
eqnull: true, | |
browser: true, | |
devel:true, | |
jquery: true | |
}, | |
globals: {} | |
}, | |
uglify: {} | |
}); | |
// Default task. | |
// run Jasmin in versbose mode (-v) to help with debugging | |
grunt.registerTask('default', 'lint jasmine concat min'); | |
// Jamsmine BDD task | |
grunt.loadNpmTasks('grunt-jasmine-task'); | |
}; |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" | |
"http://www.w3.org/TR/html4/loose.dtd"> | |
<html> | |
<head> | |
<title>Jasmine Spec Runner</title> | |
<link rel="shortcut icon" type="image/png" href="../libs/jasmine/jasmine_favicon.png"> | |
<link rel="stylesheet" type="text/css" href="../libs/jasmine/jasmine.css"> | |
<script type="text/javascript" src="../libs/jasmine/jasmine.js"></script> | |
<script type="text/javascript" src="../libs/jasmine/jasmine-html.js"></script> | |
<!-- For JUnit output of test results include the following link | |
to Lary Myer's JUnit reporter --> | |
<script type="text/javascript" src="../node_modules/grunt-jasmine-task/tasks/jasmine/jasmine-junit-reporter.js"></script> | |
<!-- include spec files here... --> | |
<script type="text/javascript" src="spec/your_spec_file_here.js"></script> | |
<!-- include source files here... --> | |
<script type="text/javascript" src="../libs/jquery/jquery.js"></script> | |
<script type="text/javascript" src="../src/your_scripts_here.js"></script> | |
</head> | |
<body> | |
<script type="text/javascript"> | |
(function() { | |
var jasmineEnv = jasmine.getEnv(); | |
jasmineEnv.updateInterval = 1000; | |
var htmlReporter = new jasmine.HtmlReporter(); | |
jasmineEnv.addReporter(htmlReporter); | |
// Specify target test results folder as below, for now | |
var junitReporter = new jasmine.JUnitXmlReporter('test-results/'); | |
jasmineEnv.addReporter(junitReporter); | |
jasmineEnv.specFilter = function(spec) { | |
return htmlReporter.specFilter(spec); | |
}; | |
var currentWindowOnload = window.onload; | |
window.onload = function() { | |
if (currentWindowOnload) { | |
currentWindowOnload(); | |
} | |
execJasmine(); | |
}; | |
function execJasmine() { | |
jasmineEnv.execute(); | |
} | |
})(); | |
</script> | |
</body> | |
</html> |
Ok, I'll need to take a longer look on this then. Don't know when I'll have the time though. I created an issue for this: https://github.com/creynders/grunt-jasmine-task/issues/10
However, 99.9% certainly I won't be integrating this straight into the grunt-jasmine-task, since I want to keep its dependencies restricted to jasmine alone. It'll have to become a separate plugin, I think.
I know I'm a year late, but I'm trying to get this to work and can't seem to. I really need the junit xml output. Running grunt jasmine gives me the following error:
"path.existsSync is now called fs.existsSync
.
Running "jasmine:junit" (jasmine) task
An error occurred while processing a template (Cannot call method 'indexOf' of undefined).
Use --force to continue. "
Any idea why if I have my files formatted as above?
Its a few things. I believe developers will want to specify the output directory. But also phantom-jasmine-runner.js in it present state dosn't play well with the Junit XML reporter.
For instance in the runner I "borrowed" from Larry's project, the JUnit is broken into files based on specs.
Since phantom.js is new to me I was happy to just add some of the functions from your runner JS to Larry Myers' runner
I ended up renaming tasks/jasmine/phantom-jasmine-runner.js → tasks/jasmine/phantom-console-runner.js
then added a tweaked version Larry's runner as tasks/jasmine/phantom-junit-runner.js
This got it working even if not in an ideal state.
Here's a link to compare my reporters branch with your master
https://github.com/asabaylus/grunt-jasmine-task/compare/master...reporters
I'd be happy for any help or advice. Thanks