Created
March 9, 2014 20:52
-
-
Save tonyhb/9454371 to your computer and use it in GitHub Desktop.
Karma + RequireJS: Mismatched anonymous define error
This file contains hidden or 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'); | |
// Plugins | |
var karma = require('gulp-karma'); | |
// Paths | |
var basePath = './public/assets/'; | |
var paths = { | |
spec: basePath + 'spec/' | |
}; | |
/** | |
* Compile SASS down to CSS using compass | |
*/ | |
function compileCSS() { | |
var stream = gulp.src(paths.sass + '*.sass') | |
.pipe(compass({ | |
css: paths.css, | |
sass: paths.sass, | |
image: paths.images, | |
style: 'nested' | |
})) | |
.on('error', console.log) | |
.pipe(gulp.dest(paths.css)); | |
return stream; | |
} | |
/** | |
* Test through Karma | |
*/ | |
var test = { | |
// Watch specs for changes and run tests on change | |
watch: function() { | |
gulp.watch(paths.spec + '**/*.coffee', ['test-compile']); | |
return test.go('watch'); | |
}, | |
// Run the tests once | |
run: function() { | |
test.compile(); | |
test.go('run'); | |
}, | |
// Test run/watch helper: either runs or launches a single test | |
go: function(action) { | |
var files = ["undefined.js"]; | |
return gulp.src(files) | |
.pipe(karma({ | |
configFile: 'karma.conf.js', | |
action: action | |
})); | |
} | |
}; | |
gulp.task('test', test.run); | |
gulp.task('test-run', test.run); | |
gulp.task('test-watch', test.watch); |
This file contains hidden or 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
module.exports = function(config) { | |
config.set({ | |
// base path, that will be used to resolve files and exclude | |
basePath: 'public', | |
// frameworks to use | |
frameworks: ['jasmine', 'requirejs'], | |
// list of files / patterns to load in the browser | |
files: [ | |
{pattern: 'assets/js/app/**/*.js', included: false}, | |
{pattern: 'assets/js/libs/**/*.js', included: false}, | |
{pattern: 'assets/spec/*Spec.js', included: false}, | |
'assets/js/app/config.js', | |
'assets/spec/test-config.js' | |
], | |
// test results reporter to use | |
// possible values: 'dots', 'progress', 'junit', 'growl', 'coverage' | |
reporters: ['progress'], | |
// 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, currently available: | |
// - Chrome | |
// - ChromeCanary | |
// - Firefox | |
// - Opera (has to be installed with `npm install karma-opera-launcher`) | |
// - Safari (only Mac; has to be installed with `npm install karma-safari-launcher`) | |
// - PhantomJS | |
// - IE (only Windows; has to be installed with `npm install karma-ie-launcher`) | |
browsers: ['PhantomJS'], | |
// If browser does not capture in given timeout [ms], kill it | |
captureTimeout: 60000, | |
// Continuous Integration mode | |
// if true, it capture browsers, run tests and exit | |
singleRun: false | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment