Fixed karma tests.
This commit is contained in:
parent
5104f0a1e7
commit
01c20f4065
4 changed files with 21 additions and 10 deletions
5
app/assets/javascripts/run-tests.js
Normal file
5
app/assets/javascripts/run-tests.js
Normal 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();
|
|
@ -3,7 +3,7 @@ template = require 'templates/test'
|
||||||
|
|
||||||
TEST_BASE_PATH = 'test/app/'
|
TEST_BASE_PATH = 'test/app/'
|
||||||
|
|
||||||
module.exports = class TestView extends CocoView
|
module.exports = TestView = class TestView extends CocoView
|
||||||
id: "test-view"
|
id: "test-view"
|
||||||
template: template
|
template: template
|
||||||
reloadOnClose: true
|
reloadOnClose: true
|
||||||
|
@ -27,7 +27,7 @@ module.exports = class TestView extends CocoView
|
||||||
scriptsLoaded: ->
|
scriptsLoaded: ->
|
||||||
@initSpecFiles()
|
@initSpecFiles()
|
||||||
@render()
|
@render()
|
||||||
@runTests()
|
TestView.runTests(@specFiles)
|
||||||
|
|
||||||
# RENDER DATA
|
# RENDER DATA
|
||||||
|
|
||||||
|
@ -89,15 +89,15 @@ module.exports = class TestView extends CocoView
|
||||||
children
|
children
|
||||||
|
|
||||||
# RUNNING TESTS
|
# RUNNING TESTS
|
||||||
|
|
||||||
initSpecFiles: ->
|
initSpecFiles: ->
|
||||||
allFiles = window.require.list()
|
@specFiles = TestView.getAllSpecFiles()
|
||||||
@specFiles = (f for f in allFiles when f.indexOf('.spec') > -1)
|
|
||||||
if @subPath
|
if @subPath
|
||||||
prefix = TEST_BASE_PATH + @subPath
|
prefix = TEST_BASE_PATH + @subPath
|
||||||
@specFiles = (f for f in @specFiles when f.startsWith prefix)
|
@specFiles = (f for f in @specFiles when f.startsWith prefix)
|
||||||
|
|
||||||
runTests: ->
|
@runTests: (specFiles) ->
|
||||||
|
specFiles ?= @getAllSpecFiles()
|
||||||
describe 'CodeCombat Client', =>
|
describe 'CodeCombat Client', =>
|
||||||
jasmine.Ajax.install()
|
jasmine.Ajax.install()
|
||||||
beforeEach ->
|
beforeEach ->
|
||||||
|
@ -111,7 +111,11 @@ module.exports = class TestView extends CocoView
|
||||||
# TODO Clean up more things
|
# TODO Clean up more things
|
||||||
# * Events
|
# * 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: ->
|
destroy: ->
|
||||||
# hack to get jasmine tests to properly run again on clicking links, and make sure if you
|
# hack to get jasmine tests to properly run again on clicking links, and make sure if you
|
||||||
|
|
|
@ -13,9 +13,11 @@ module.exports = function(config) {
|
||||||
files : [
|
files : [
|
||||||
'public/javascripts/vendor.js',
|
'public/javascripts/vendor.js',
|
||||||
'public/lib/ace/ace.js',
|
'public/lib/ace/ace.js',
|
||||||
|
'public/javascripts/aether.js',
|
||||||
'public/javascripts/app.js',
|
'public/javascripts/app.js',
|
||||||
|
'public/javascripts/mock-ajax.js',
|
||||||
'test/app/**/*.coffee'
|
'public/javascripts/test-app.js',
|
||||||
|
'public/javascripts/run-tests.js'
|
||||||
],
|
],
|
||||||
|
|
||||||
preprocessors : {
|
preprocessors : {
|
||||||
|
|
|
@ -91,7 +91,7 @@
|
||||||
"karma-firefox-launcher": "~0.1.3",
|
"karma-firefox-launcher": "~0.1.3",
|
||||||
"karma-html2js-preprocessor": "~0.1.0",
|
"karma-html2js-preprocessor": "~0.1.0",
|
||||||
"karma-coffee-preprocessor": "~0.1.2",
|
"karma-coffee-preprocessor": "~0.1.2",
|
||||||
"karma-jasmine": "~0.1.5",
|
"karma-jasmine": "~0.2.0",
|
||||||
"requirejs": "~2.1.10",
|
"requirejs": "~2.1.10",
|
||||||
"karma-requirejs": "~0.2.1",
|
"karma-requirejs": "~0.2.1",
|
||||||
"karma-phantomjs-launcher": "~0.1.1",
|
"karma-phantomjs-launcher": "~0.1.1",
|
||||||
|
|
Reference in a new issue