Last active
August 29, 2015 14:00
-
-
Save diegotoral/11198482 to your computer and use it in GitHub Desktop.
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'), | |
karma = require('gulp-karma'), | |
jshint = require('gulp-jshint'); | |
// Server configurations | |
var SERVER_PORT = 8080, | |
SERVER_ROOT = __dirname; | |
// Test files | |
var testFiles = [ | |
'bower_components/jquery/dist/jquery.min.js', | |
'bower_components/underscore/underscore.js', | |
'bower_components/backbone/backbone.js', | |
'bower_components/jasmine-jquery/lib/jasmine-jquery.js', | |
'js/models/*.js', | |
'js/collections/*.js', | |
'js/views/*.js', | |
'js/app.js', | |
'spec/**/*.js', | |
'index.html' | |
]; | |
gulp.task('server', function() { | |
var express = require('express'), | |
app = express(); | |
app.use(express.static(SERVER_ROOT)); | |
app.listen(SERVER_PORT); | |
console.log('Server started! http://localhost:' + SERVER_PORT); | |
}); | |
gulp.task('jshint', function () { | |
gulp.src(['js/**/*.js']) | |
.pipe(jshint('.jshintrc')) | |
.pipe(jshint.reporter('jshint-stylish')); | |
}); | |
gulp.task('test', function() { | |
return gulp.src(testFiles) | |
.pipe(karma({ | |
configFile: 'karma.conf.js', | |
action: 'watch' | |
})) | |
.on('error', function(err) { | |
throw err; | |
}); | |
}); | |
gulp.task('default', ['jshint', 'server', 'test'], function() {}); |
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
PhantomJS 1.9.7 (Linux) ERROR | |
Error: Fixture could not be loaded: /index.html (status: error, message: undefined) | |
at /home/.../bower_components/jasmine-jquery/lib/jasmine-jquery.js:130 |
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
// Karma configuration | |
// Generated on Tue Apr 15 2014 21:11:05 GMT-0300 (BRT) | |
module.exports = function(config) { | |
config.set({ | |
// base path that will be used to resolve all patterns (eg. files, exclude) | |
basePath: '.', | |
// frameworks to use | |
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter | |
frameworks: ['jasmine'], | |
// list of files / patterns to load in the browser | |
files: [ | |
'bower_components/jquery/dist/jquery.min.js', | |
'bower_components/underscore/underscore.js', | |
'bower_components/backbone/backbone.js', | |
'bower_components/jasmine-jquery/lib/jasmine-jquery.js', | |
'js/**/*.js', | |
'spec/**/*.js', | |
// Fixtures | |
{ | |
pattern: 'index.html', | |
watched: true, | |
included: true, | |
served: true | |
} | |
], | |
// list of files to exclude | |
exclude: [ | |
], | |
// preprocess matching files before serving them to the browser | |
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor | |
preprocessors: { | |
}, | |
// test results reporter to use | |
// possible values: 'dots', 'progress' | |
// available reporters: https://npmjs.org/browse/keyword/karma-reporter | |
reporters: ['dots'], | |
// web server port | |
port: 9876, | |
// enable / disable colors in the output (reporters and logs) | |
colors: true, | |
// level of logging | |
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG | |
logLevel: config.LOG_INFO, | |
// enable / disable watching file and executing tests whenever any file changes | |
autoWatch: true, | |
// start these browsers | |
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher | |
browsers: ['PhantomJS'], | |
// Continuous Integration mode | |
// if true, Karma captures browsers, runs the tests and exits | |
singleRun: false | |
}); | |
}; |
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
describe('NewActivityView', function() { | |
var view; | |
beforeEach(function() { | |
jasmine.getFixtures().fixturesPath = ''; | |
loadFixtures('index.html'); | |
view = new app.NewActivityView(); | |
}); | |
it('should bind $el to the right DOM element', function() { | |
expect(view.$el.selector).toBe('section#new-activity'); | |
}); | |
it('should return the user input for the activity time', function() { | |
view.$('input[name="duration"]').val(1234); | |
expect(view.getDuration()).toEqual(1234); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment