Skip to content

Instantly share code, notes, and snippets.

@andrewk
Last active August 29, 2015 13:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewk/9757876 to your computer and use it in GitHub Desktop.
Save andrewk/9757876 to your computer and use it in GitHub Desktop.
Welcome to 2014, where apparently we need all this bullshit.
{
"name": "WhiskyTimeBitches",
"version": "0.0.0",
"dependencies": {
"jquery": "2.x.x",
"requirejs": "~2.1.8",
"jasmine-jquery": "~2.0.3",
"jasmine-ajax": "~1.3.1"
}
}
// Karma configuration
//
// For all available config options and default values, see:
// http://karma-runner.github.io/0.10/config/configuration-file.html
module.exports = function (config) {
'use strict';
config.set({
// base path, that will be used to resolve files and exclude
basePath: '',
preprocessors: {},
// frameworks to use
frameworks: ['jasmine'],
// list of files / patterns to load in the browser
files: [
// loaded without require
'assets/components/es5-shim/es5-shim.js',
'assets/components/es5-shim/es5-sham.js',
'assets/components/jquery/dist/jquery.js',
'assets/components/jasmine-jquery/lib/jasmine-jquery.js',
'assets/components/jasmine-ajax/lib/mock-ajax.js',
'assets/components/jasmine-flight/lib/jasmine-flight.js',
// hack to load RequireJS after the shim libs
'node_modules/requirejs/require.js',
'node_modules/karma-requirejs/lib/adapter.js',
// loaded with require
{pattern: 'assets/js/**/*.js', included: false},
{pattern: 'test/spec/**/*.spec.js', included: false},
{pattern: 'test/fixtures/**/*.html', included: false},
'test/test-main.js'
],
// list of files to exclude
exclude: [],
// test results reporter to use
// possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
reporters: ['progress'],
// 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: 5000,
// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun: false,
// Karma will report all the tests that are slower than given time limit (in
// ms).
reportSlowerThan: 500
});
};
.PHONY: setup test
setup:
mkdir test
mkdir test/specs
mkdir test/fixtures
mkdir assets
mkdir assets/js
mkdir assets/css
mv test-main.js ./test/
npm install
bower install
test:
./node_modules/karma start --single-run --browsers PhantomJS
{
"name": "THING FOR LACHLAN",
"version": "0.0.1",
"repository": {
"type": "git",
"url": ""
},
"dependencies": {
"bower": "~1.3",
"gulp": "~3.4.0",
"gulp-livereload": "~0.2.0",
"karma": "~0.10.0",
"karma-jasmine": "~0.1.0",
"karma-requirejs": "~0.2.1",
"karma-chrome-launcher": "~0.1.0",
"karma-firefox-launcher": "~0.1.0",
"karma-phantomjs-launcher": "~0.1.0",
"node-static": "~0.7.3",
"tiny-lr": "0.0.5",
"requirejs": "~2.1.11"
},
"scripts": {
"livereload": "gulp",
"start": "static app",
"test": "karma start --single-run --browsers PhantomJS",
"watch": "npm run start > server.log & npm run livereload",
"watch-test": "karma start"
}
}
//--------------------------------------
// Put this file in 'test' directory
//--------------------------------------
'use strict';
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: {
'js': 'assets/js'
},
// ask Require.js to load these files (all our tests)
deps: tests,
// start test run, once Require.js is done
callback: window.__karma__.start
});
jasmine.getFixtures().fixturesPath = 'base/test/fixtures';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment