Skip to content

Commit

Permalink
integrate karma/jasmine for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
mjneil committed Feb 20, 2016
1 parent a38f1a1 commit aafd108
Show file tree
Hide file tree
Showing 6 changed files with 216 additions and 113 deletions.
154 changes: 46 additions & 108 deletions CruftEngine.sublime-workspace
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,6 @@
},
"buffers":
[
{
"file": "index.js",
"settings":
{
"buffer_size": 0,
"line_ending": "Unix"
}
},
{
"contents": "",
"file": "Gulpfile.js",
Expand All @@ -34,35 +26,24 @@
"line_ending": "Unix"
}
},
{
"file": "game/TESTFILE.json",
"settings":
{
"buffer_size": 0,
"line_ending": "Unix"
}
},
{
"file": "game/index.html",
"settings":
{
"buffer_size": 0,
"line_ending": "Unix"
}
},
{
"file": "package.json",
"settings":
{
"buffer_size": 0,
"buffer_size": 891,
"line_ending": "Unix"
}
}
],
"build_system": "",
"build_system_choices":
[
],
"build_varint": "",
"command_palette":
{
"height": 102.0,
"last_filter": "",
"selected_items":
[
[
Expand All @@ -78,7 +59,11 @@
},
"console":
{
"height": 132.0
"height": 132.0,
"history":
[
"import urllib.request,os,hashlib; h = 'eb2297e1a458f27d836c04bb0cbaf282' + 'd0e7a3098092775ccb37ca9d6b2e4b7d'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by)"
]
},
"distraction_free":
{
Expand All @@ -91,6 +76,9 @@
},
"file_history":
[
"/C/cygwin64/home/Matthew/CruftEngine/game/index.html",
"/C/cygwin64/home/Matthew/CruftEngine/game/TESTFILE.json",
"/C/cygwin64/home/Matthew/CruftEngine/index.js",
"/home/yusef/Documents/dev/cruft/game/engine/package.json",
"/home/yusef/Documents/dev/cruft/game/engine/core/http.js",
"/home/yusef/Documents/dev/cruft/game/engine/core/Cache.js",
Expand Down Expand Up @@ -150,38 +138,13 @@
"groups":
[
{
"selected": 1,
"selected": 0,
"sheets":
[
{
"buffer": 0,
"file": "index.js",
"settings":
{
"buffer_size": 0,
"regions":
{
},
"selection":
[
[
0,
0
]
],
"settings":
{
"syntax": "Packages/JavaScript/JavaScript.tmLanguage"
},
"translation.x": 0.0,
"translation.y": 0.0,
"zoom_level": 1.0
},
"type": "text"
},
{
"buffer": 1,
"file": "Gulpfile.js",
"semi_transient": false,
"settings":
{
"buffer_size": 0,
Expand All @@ -203,66 +166,16 @@
"translation.y": 0.0,
"zoom_level": 1.0
},
"stack_index": 0,
"type": "text"
},
{
"buffer": 2,
"file": "game/TESTFILE.json",
"settings":
{
"buffer_size": 0,
"regions":
{
},
"selection":
[
[
0,
0
]
],
"settings":
{
"syntax": "Packages/JavaScript/JSON.tmLanguage"
},
"translation.x": 0.0,
"translation.y": 0.0,
"zoom_level": 1.0
},
"type": "text"
},
{
"buffer": 3,
"file": "game/index.html",
"settings":
{
"buffer_size": 0,
"regions":
{
},
"selection":
[
[
0,
0
]
],
"settings":
{
"syntax": "Packages/HTML/HTML.tmLanguage"
},
"translation.x": 0.0,
"translation.y": 0.0,
"zoom_level": 1.0
},
"type": "text"
},
{
"buffer": 4,
"buffer": 1,
"file": "package.json",
"semi_transient": false,
"settings":
{
"buffer_size": 0,
"buffer_size": 891,
"regions":
{
},
Expand All @@ -283,6 +196,7 @@
"translation.y": 0.0,
"zoom_level": 1.0
},
"stack_index": 1,
"type": "text"
}
]
Expand Down Expand Up @@ -319,6 +233,12 @@
]
},
"menu_visible": true,
"output.find_results":
{
"height": 0.0
},
"pinned_build_system": "",
"project": "CruftEngine.sublime-project",
"replace":
{
"height": 0.0
Expand All @@ -327,6 +247,7 @@
"select_file":
{
"height": 0.0,
"last_filter": "",
"selected_items":
[
],
Expand All @@ -335,15 +256,32 @@
"select_project":
{
"height": 0.0,
"last_filter": "",
"selected_items":
[
],
"width": 0.0
},
"select_symbol":
{
"height": 0.0,
"last_filter": "",
"selected_items":
[
],
"width": 0.0
},
"selected_group": 0,
"settings":
{
},
"show_minimap": true,
"show_open_files": false,
"show_tabs": true,
"side_bar_visible": true,
"side_bar_width": 150.0,
"status_bar_visible": true
"status_bar_visible": true,
"template_settings":
{
}
}
8 changes: 8 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ var gls = require('gulp-live-server');
var runSequence = require('run-sequence');
var cache = require('gulp-cached');
var server = gls.new("server.js");
var karma = require('karma').Server;

var ENGINE_SRC = ["engine/**/*.js"];

Expand Down Expand Up @@ -89,6 +90,13 @@ gulp.task("server", function () {
server.start();
})

gulp.task('test:single', function (done) {
new karma({
configFile: __dirname + '/karma.conf.js',
singleRun: true
}, done).start();
});

//echo fs.inotify.max_user_watches=582222 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
gulp.task("default", function () {
runSequence(
Expand Down
90 changes: 90 additions & 0 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
// Karma configuration
// Generated on Sat Feb 20 2016 13:01:48 GMT-0600 (Central Standard Time)

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: ['requirejs', 'traceur', 'jasmine'],


// list of files / patterns to load in the browser
files: [
{ pattern: 'engine/**/*.js', included: false },
{ pattern: 'tests/**/*.test.js', included: false },
'tests/main-test.js'
],


// 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: {
'engine/**/*.js': ['traceur'],
'tests/**/*.test.js': ['traceur']
},

traceurPreprocessor: {
// options passed to the traceur-compiler
// see traceur --longhelp for list of options
options: {
experimental: true,
sourceMaps: true,
modules: 'amd'
}
},

// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
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: false,


// 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,

// Concurrency level
// how many browser should be started simultaneous
concurrency: Infinity,

plugins: [
'karma-requirejs',
'karma-traceur-preprocessor',
'karma-jasmine',
'karma-chrome-launcher',
'karma-phantomjs-launcher'
]
})
}
Loading

0 comments on commit aafd108

Please sign in to comment.