lawl-spec-reporter
Version:
Spec reporter for jasmine, based on jasmine-spec-reporter, outputs in LolSpeak
464 lines (383 loc) • 12.6 kB
text/coffeescript
require('./helpers/test-helper.coffee')
SpecReporter = require('../src/lawl-spec-reporter.js')
describe 'spec reporter', ->
addMatchers()
describe 'with default options', ->
beforeEach ->
= new SpecReporter()
describe 'when spec', ->
it 'should report success', ->
expect(new Test(,->
'suite', ->
'successful spec', ->
).outputs)
.contains /✓ SUCCESSFUL SPEC/
it 'should report failure', ->
expect(new Test(,->
'suite', ->
'failed spec', ->
).outputs)
.contains /✗ FAILD SPEC/
it 'should not report pending', ->
expect(new Test(,->
'suite', ->
'pending spec', ->
).outputs)
.not.contains /PENDING SPEC/
describe 'when failed spec', ->
it 'should display with error messages', ->
outputs = new Test(,->
'suite', ->
'failed spec', ->
).outputs
expect(outputs).not.contains /passed assertion/
expect(outputs).contains [
' ✗ FAILD SPEC'
' - first failed assertion'
' - second failed assertion'
''
]
describe 'when suite', ->
it 'should display multiple specs', ->
expect(new Test(,->
'suite', ->
'spec 1', ->
'spec 2', ->
).outputs).contains [
''
' SUITE'
' ✓ SPEC 1'
' ✓ SPEC 2'
''
]
it 'should display multiple suites', ->
expect(new Test(,->
'suite 1', ->
'spec 1', ->
'suite 2', ->
'spec 2', ->
).outputs).contains [
''
' SUITE 1'
' ✓ SPEC 1'
''
' SUITE 2'
' ✓ SPEC 2'
''
]
it 'should display nested suite at first position', ->
expect(new Test(,->
'suite 1', ->
'suite 2', ->
'spec 1', ->
'spec 2', ->
).outputs).contains [
''
' SUITE 1'
''
' SUITE 2'
' ✓ SPEC 1'
''
' ✓ SPEC 2'
''
]
it 'should display nested suite at last position', ->
expect(new Test(,->
'suite 1', ->
'spec 1', ->
'suite 2', ->
'spec 2', ->
).outputs).contains [
''
' SUITE 1'
' ✓ SPEC 1'
''
' SUITE 2'
' ✓ SPEC 2'
''
]
it 'should display multiple nested suites', ->
expect(new Test(,->
'suite 1', ->
'suite 2', ->
'spec 2', ->
'suite 3', ->
'spec 3', ->
).outputs).contains [
''
' SUITE 1'
''
' SUITE 2'
' ✓ SPEC 2'
''
' SUITE 3'
' ✓ SPEC 3'
''
]
describe 'when summary', ->
it 'should report success', ->
expect(new Test(,->
'suite', ->
'spec', ->
).summary)
.contains 'EXECUTD 1 OV 1 SPEC SUCCES IN {time}.'
it 'should report failure', ->
expect(new Test(,->
'suite', ->
'spec', ->
).summary)
.contains 'EXECUTD 1 OV 1 SPEC (1 FAILD) IN {time}.'
#TODO: Make this work
xit 'should report failures summary', ->
expect(new Test(,->
'suite 1', ->
'spec 1', ->
'suite 2', ->
'spec 2', ->
).summary).contains [
/[\s\S]*/
/OH NOES/
/[\s\S]*/
/1\) SUITE 1 SPEC 1/
/- failed assertion 1/
/[\s\S]*/
]
it 'should report pending with success', ->
expect(new Test(,->
'suite', ->
'spec', ->
).summary)
.contains 'EXECUTD 0 OV 1 SPEC SUCCES (1 PENDIN) IN {time}.'
it 'should report pending with failure', ->
expect(new Test(,->
'suite', ->
'spec', ->
'spec', ->
).summary)
.contains 'EXECUTD 1 OV 2 SPECZ (1 FAILD) (1 PENDIN) IN {time}.'
xit 'should report skipped with success', ->
expect(new Test(,->
'suite', ->
'spec', ->
'spec', ->
).summary)
.toContain 'EXECUTD 1 OV 1 SPEC SUCCES (1 SKIPPED) IN {time}.'
xit 'should report skipped with failure and pending', ->
expect(new Test(,->
'suite', ->
'spec', ->
'spec', ->
'suite', ->
'spec', ->
'spec', ->
).summary)
.toContain 'EXECUTD 1 OV 2 SPECZ (1 FAILD) (1 PENDING) (2 SKIPPED) IN {time}.'
describe 'with stacktrace enabled', ->
beforeEach ->
= new SpecReporter({displayStacktrace: true})
describe 'when failed spec', ->
it 'should display with error messages with stacktraces', ->
outputs = new Test(,->
'suite', ->
'failed spec', ->
).outputs
expect(outputs).not.contains /passed assertion/
expect(outputs).contains [
' ✗ FAILD SPEC'
' - first failed assertion'
' {Stacktrace}'
''
]
#TODO: Make this work
describe 'when summary', ->
xit 'should report failures summary with stacktraces', ->
expect(new Test(,->
'suite 1', ->
'spec 1', ->
'suite 2', ->
'spec 2', ->
).summary).contains [
/[\s\S]*/
/OH NOES/
/[\s\S]*/
/1\) SUITE 1 SPEC 1/
/- failed assertion 1/
' {Stacktrace}'
/[\s\S]*/
]
describe 'with failures summary disabled', ->
beforeEach ->
= new SpecReporter({displayFailuresSummary: false})
describe 'when summary', ->
it 'should not report failures summary', ->
expect(new Test(,->
'suite 1', ->
'spec 1', ->
'suite 2', ->
'spec 2', ->
).summary).not.contains /OH NOES/
describe 'with successful spec disabled', ->
beforeEach ->
= new SpecReporter({displaySuccessfulSpec: false})
describe 'when spec', ->
it 'should not report success', ->
expect(new Test(,->
'suite', ->
'successful spec', ->
).outputs)
.not.contains /SUCCESSFUL SPEC/
describe 'when suite', ->
it 'should not display successful suite', ->
outputs = new Test(,->
'suite', ->
'spec 1', ->
'spec 2', ->
).outputs
expect(outputs).not.contains /SUITE/
it 'should display failed suite', ->
outputs = new Test(,->
'suite', ->
'failed spec', ->
'successful spec', ->
).outputs
expect(outputs).contains /SUITE/
expect(outputs).contains /FAILD SPEC/
expect(outputs).not.contains /SUCCESSFUL SPEC/
describe 'with failed spec disabled', ->
beforeEach ->
= new SpecReporter({displayFailedSpec: false})
describe 'when spec', ->
it 'should not report failed', ->
expect(new Test(,->
'suite', ->
'failed spec', ->
).outputs)
.not.contains /FAILD SPEC/
describe 'when suite', ->
it 'should not display fully failed suite', ->
expect(new Test(,->
'failed suite', ->
'spec 1', ->
'spec 2', ->
).outputs).not.contains /FAILD SUITE/
it 'should display not fully failed suite', ->
outputs = new Test(,->
'failed suite', ->
'successful spec', ->
'failed spec', ->
).outputs
expect(outputs).contains /FAILD SUITE/
expect(outputs).contains /SUCCESSFUL SPEC/
expect(outputs).not.contains /FAILD SPEC/
describe 'with pending spec enabled', ->
beforeEach ->
= new SpecReporter({displayPendingSpec: true})
describe 'when spec', ->
it 'should report pending', ->
expect(new Test(,->
'suite', ->
'pending spec', ->
).outputs)
.contains /- PENDING SPEC/
describe 'with spec duration enabled', ->
beforeEach ->
= new SpecReporter({displaySpecDuration: true})
describe 'when spec', ->
it 'should report success', ->
expect(new Test(,->
'suite', ->
'successful spec', ->
).outputs)
.contains /✓ SUCCESSFUL SPEC \(\{time}\)/
it 'should report failure', ->
expect(new Test(,->
'suite', ->
'failed spec', ->
).outputs)
.contains /✗ FAILD SPEC \(\{time}\)/
describe 'with prefixes set to empty strings', ->
beforeEach ->
= new SpecReporter({displayPendingSpec: true, prefixes: {success: '', failure: '', pending: ''}})
describe 'when spec', ->
it 'should report success', ->
expect(new Test(,->
'suite', ->
'successful spec', ->
).outputs)
.not.contains /✓/
it 'should report failure', ->
expect(new Test(,->
'suite', ->
'failed spec', ->
).outputs)
.not.contains /✗/
it 'should report pending', ->
expect(new Test(,->
'suite', ->
'pending spec', ->
).outputs)
.not.contains /-/
describe 'with prefixes set to valid strings', ->
beforeEach ->
= new SpecReporter({displayPendingSpec: true, prefixes: {success: 'Pass ', failure: 'Fail ', pending: 'Skip '}})
describe 'when spec', ->
it 'should report success', ->
expect(new Test(,->
'suite', ->
'successful spec', ->
).outputs)
.not.contains /✓/
it 'should report failure', ->
expect(new Test(,->
'suite', ->
'failed spec', ->
).outputs)
.not.contains /✗/
it 'should report pending', ->
expect(new Test(,->
'suite', ->
'pending spec', ->
).outputs)
.not.contains /-/