Skip to content

Instantly share code, notes, and snippets.

@hassox
Created July 24, 2012 21:08
Show Gist options
  • Save hassox/3172672 to your computer and use it in GitHub Desktop.
Save hassox/3172672 to your computer and use it in GitHub Desktop.
function thisIsATest(){
return true;
}
var testacular = require('testacular');
/*global module:false*/
module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-coffee');
// Project configuration.
grunt.initConfig({
clean: ["../public/assets/js/debug", "../public/assets/js/release"],
lint: {
files: [
'grunt.js',
'app/**/*.js'
]
},
spec: {
files: ['spec/javascripts/**/*.js']
},
coffee: {
build: {
src: ['spec/**/*.coffee']
}
},
watch: {
files: ['<config:coffee.build.src>'],
tasks: 'coffee'
},
jshint: {
options: {
curly: true,
eqeqeq: true,
immed: true,
latedef: true,
newcap: true,
noarg: true,
sub: true,
undef: true,
boss: true,
eqnull: true
},
globals: {
jQuery: true
}
}
});
// Default task.
grunt.registerTask('default');
grunt.registerTask('server','start testacular server', function(){
// mark the task as async but never call done so t5he server stays up.
var done = this.async();
testacular.server.start('spec/testacular.config.js');
});
grunt.registerTask('test', 'run tests (make sure server task is run first)', function() {
var done = this.async();
grunt.utils.spawn({
cmd: 'testacular-run',
args: ['spec/testacular.config.js']
}, function(error, result, code) {
if (error) {
grunt.warn("Make sure the testacular server is online: run `grunt server`.\n"+
"Also make sure you have a browser open to http://localhost:8080/.\n"+
error.stdout+error.stderr);
//the testacular runner somehow modifies the files if it errors(??).
//this causes grunt's watch task to re-fire itself constantly,
//unless we wait for a sec
setTimeout(done, 1000);
} else {
grunt.log.write(result.stdout);
done();
}
});
});
};
// = require application
describe("a js spec", function(){
it("should load my application", function(){
expect(thisIsATest()).toBeTrue();
});
it("should be a success", function(){
expect(true).toEqual(true);
});
});
// Sample Testacular configuration file, that contain pretty much all the available options
// It's used for running client tests on Travis (http://travis-ci.org/#!/vojtajina/testacular)
// Most of the options can be overriden by cli arguments (see testacular --help)
// base path, that will be used to resolve files and exclude
basePath = 'javascripts';
// list of files / patterns to load in the browser
files = [
JASMINE,
JASMINE_ADAPTER,
'*_spec.js',
'*/*_spec.js'
];
// list of files to exclude
exclude = [];
// use dots reporter, as travis terminal does not support escaping sequences
// possible values: 'dots' || 'progress'
reporter = 'progress';
// web server port
port = 8080;
// cli runner port
runnerPort = 9100;
// enable / disable colors in the output (reporters and logs)
colors = true;
// level of logging
// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG
logLevel = LOG_INFO;
// enable / disable watching file and executing tests whenever any file changes
autoWatch = true;
// polling interval in ms (ignored on OS that support inotify)
autoWatchInterval = 100;
// Start these browsers, currently available:
// - Chrome
// - ChromeCanary
// - Firefox
// - Opera
// - Safari
// - PhantomJS
browsers = ["Safari"];
// Auto run tests on start (when browsers are captured) and exit
singleRun = false;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment