Last active
December 21, 2015 17:18
-
-
Save jhohlfeld/6339219 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
// Karma configuration | |
// Generated on Mon Aug 26 2013 10:52:29 GMT+0200 (CEST) | |
module.exports = function(karma) { | |
karma.configure({ | |
// base path, that will be used to resolve files and exclude | |
basePath: '', | |
// frameworks to use | |
frameworks: ['jasmine', 'requirejs'], | |
// list of files / patterns to load in the browser | |
files: [ | |
'test-main.js', | |
{pattern: 'Spec.js', included: false}, | |
{pattern: '*.html', included: false} | |
], | |
// list of files to exclude | |
exclude: [ | |
], | |
// test results reporter to use | |
// possible values: 'dots', 'progress', 'junit', 'growl', 'coverage' | |
reporters: ['progress'], | |
// web server port | |
port: 9876, | |
// cli runner port | |
runnerPort: 9100, | |
// enable / disable colors in the output (reporters and logs) | |
colors: true, | |
// level of logging | |
// possible values: karma.LOG_DISABLE || karma.LOG_ERROR || karma.LOG_WARN || karma.LOG_INFO || karma.LOG_DEBUG | |
logLevel: karma.LOG_INFO, | |
// enable / disable watching file and executing tests whenever any file changes | |
autoWatch: true, | |
// Start these browsers, currently available: | |
// - Chrome | |
// - ChromeCanary | |
// - Firefox | |
// - Opera | |
// - Safari (only Mac) | |
// - PhantomJS | |
// - IE (only Windows) | |
browsers: ['Chrome'], | |
// 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, | |
// disable html2js preprocessor because it's breaking | |
// loading behavior of requirejs | |
preprocessors: { } | |
}); | |
}; |
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
<h1>Hey, I am some template</h> |
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
define(['jquery', 'text!some_template.html'], function($, html) { | |
// this will not work: window.__html__ will be undefined! | |
// var html = window.__html__['/base/some_template.html']; | |
/** | |
* Test case: | |
* Let requirejs-text load the assets. | |
*/ | |
describe('It', function() { | |
it('loads html', function() { | |
expect(html).toContain('<h1>Hey, I am some template</h>'); | |
}); | |
}); | |
}); |
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 tests = Object.keys(window.__karma__.files).filter(function(file) { | |
return /Spec\.js$/.test(file); | |
}); | |
requirejs.config({ | |
// Karma serves files from '/base' | |
baseUrl: '/base', | |
paths: { | |
'jquery': '//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.3/jquery.min', | |
'text': '//cdnjs.cloudflare.com/ajax/libs/require-text/2.0.10/text' | |
}, | |
// ask Require.js to load these files (all our tests) | |
deps: tests, | |
// start test run, once Require.js is done | |
callback: window.__karma__.start | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment