Add clearer reports to client TestView

This commit is contained in:
Scott Erickson 2016-06-03 16:26:03 -07:00
parent 3f8272afe9
commit 7a0fb967f0
3 changed files with 60 additions and 18 deletions

View file

@ -7,3 +7,7 @@
font-family: Arial, Geneva, sans-serif
padding: 20px
font-weight: bold
.alert-report
font-size: 20px

View file

@ -11,6 +11,20 @@ ol.breadcrumb
.container-fluid
.row
.col-md-8
#failure-reports
for report in view.failureReports
.alert.alert-danger.alert-report
ul.suite-list
for description in report.suiteDescriptions
li= description
li
strong ... #{report.testDescription}
hr
ol.error-list
for message in report.failMessages
li
strong= message
#test-wrapper.well
#testing-area

View file

@ -13,7 +13,7 @@ module.exports = TestView = class TestView extends RootView
id: 'test-view'
template: template
reloadOnClose: true
loadedFileIDs: []
className: 'style-flat'
events:
'click #show-demos-btn': 'onClickShowDemosButton'
@ -24,11 +24,13 @@ module.exports = TestView = class TestView extends RootView
initialize: (options, @subPath='') ->
@subPath = @subPath[1..] if @subPath[0] is '/'
@demosOn = storage.load('demos-on')
@failureReports = []
@loadedFileIDs = []
afterInsert: ->
@initSpecFiles()
@render()
TestView.runTests(@specFiles, @demosOn)
TestView.runTests(@specFiles, @demosOn, @)
window.runJasmine()
# EVENTS
@ -59,7 +61,30 @@ module.exports = TestView = class TestView extends RootView
prefix = TEST_REQUIRE_PREFIX + @subPath
@specFiles = (f for f in @specFiles when _.string.startsWith f, prefix)
@runTests: (specFiles, demosOn=false) ->
@runTests: (specFiles, demosOn=false, view) ->
jasmine.getEnv().addReporter({
suiteStack: []
specDone: (result) ->
if result.status is 'failed'
console.log 'result', result
report = {
suiteDescriptions: _.clone(@suiteStack)
failMessages: (fe.message for fe in result.failedExpectations)
testDescription: result.description
}
view.failureReports.push(report)
view.renderSelectors('#failure-reports')
suiteStarted: (result) ->
@suiteStack.push(result.description)
suiteDone: (result) ->
@suiteStack.pop()
})
application.testing = true
specFiles ?= @getAllSpecFiles()
if demosOn
@ -71,23 +96,22 @@ module.exports = TestView = class TestView extends RootView
jasmine.demoEl = _.noop
jasmine.demoModal = _.noop
describe 'CodeCombat Client', =>
jasmine.Ajax.install()
beforeEach ->
jasmine.Ajax.requests.reset()
Backbone.Mediator.init()
Backbone.Mediator.setValidationEnabled false
spyOn(application.tracker, 'trackEvent')
# TODO Stubbify more things
# * document.location
# * firebase
# * all the services that load in main.html
jasmine.Ajax.install()
beforeEach ->
jasmine.Ajax.requests.reset()
Backbone.Mediator.init()
Backbone.Mediator.setValidationEnabled false
spyOn(application.tracker, 'trackEvent')
# TODO Stubbify more things
# * document.location
# * firebase
# * all the services that load in main.html
afterEach ->
# TODO Clean up more things
# * Events
afterEach ->
# 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()