Fixed karma tests.

This commit is contained in:
Scott Erickson 2014-06-07 18:15:57 -07:00
parent 5104f0a1e7
commit 01c20f4065
4 changed files with 21 additions and 10 deletions

View file

@ -0,0 +1,5 @@
// Helper for running tests through Karma.
// Hooks into the test view logic for running tests.
TestView = require('views/test');
TestView.runTests();

View file

@ -3,7 +3,7 @@ template = require 'templates/test'
TEST_BASE_PATH = 'test/app/'
module.exports = class TestView extends CocoView
module.exports = TestView = class TestView extends CocoView
id: "test-view"
template: template
reloadOnClose: true
@ -27,7 +27,7 @@ module.exports = class TestView extends CocoView
scriptsLoaded: ->
@initSpecFiles()
@render()
@runTests()
TestView.runTests(@specFiles)
# RENDER DATA
@ -89,15 +89,15 @@ module.exports = class TestView extends CocoView
children
# RUNNING TESTS
initSpecFiles: ->
allFiles = window.require.list()
@specFiles = (f for f in allFiles when f.indexOf('.spec') > -1)
@specFiles = TestView.getAllSpecFiles()
if @subPath
prefix = TEST_BASE_PATH + @subPath
@specFiles = (f for f in @specFiles when f.startsWith prefix)
runTests: ->
@runTests: (specFiles) ->
specFiles ?= @getAllSpecFiles()
describe 'CodeCombat Client', =>
jasmine.Ajax.install()
beforeEach ->
@ -111,7 +111,11 @@ module.exports = class TestView extends CocoView
# TODO Clean up more things
# * Events
require f for f in @specFiles # runs the tests
require f for f in specFiles # runs the tests
@getAllSpecFiles = ->
allFiles = window.require.list()
(f for f in allFiles when f.indexOf('.spec') > -1)
destroy: ->
# hack to get jasmine tests to properly run again on clicking links, and make sure if you

View file

@ -13,9 +13,11 @@ module.exports = function(config) {
files : [
'public/javascripts/vendor.js',
'public/lib/ace/ace.js',
'public/javascripts/aether.js',
'public/javascripts/app.js',
'test/app/**/*.coffee'
'public/javascripts/mock-ajax.js',
'public/javascripts/test-app.js',
'public/javascripts/run-tests.js'
],
preprocessors : {

View file

@ -91,7 +91,7 @@
"karma-firefox-launcher": "~0.1.3",
"karma-html2js-preprocessor": "~0.1.0",
"karma-coffee-preprocessor": "~0.1.2",
"karma-jasmine": "~0.1.5",
"karma-jasmine": "~0.2.0",
"requirejs": "~2.1.10",
"karma-requirejs": "~0.2.1",
"karma-phantomjs-launcher": "~0.1.1",