Skip to content
This repository was archived by the owner on Nov 8, 2024. It is now read-only.

Commit 380c050

Browse files
authored
Merge pull request #608 from apiaryio/honzajavorek/fix-dot-reporter
Fixed dot reporter
2 parents f18ebce + 5cb3fee commit 380c050

File tree

3 files changed

+47
-33
lines changed

3 files changed

+47
-33
lines changed

src/dredd.coffee

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ class Dredd
4747
configureReporters @configuration, @stats, @tests, @runner
4848

4949
run: (callback) ->
50-
5150
@configDataIsEmpty = true
5251

5352
@configuration.files ?= []

src/reporters/dot-reporter.coffee

Lines changed: 45 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,66 @@
1-
logger = require './../logger'
2-
prettifyResponse = require './../prettify-response'
1+
2+
logger = require('../logger')
3+
prettifyResponse = require('../prettify-response')
4+
35

46
class DotReporter
7+
58
constructor: (emitter, stats, tests) ->
6-
@type = "dot"
9+
@type = 'dot'
710
@stats = stats
811
@tests = tests
9-
@configureEmitter emitter
12+
@configureEmitter(emitter)
1013
@errors = []
1114

12-
configureEmitter: (emitter) =>
13-
emitter.on 'start', ->
14-
logger.info 'Beginning Dredd testing...'
15+
configureEmitter: (emitter) ->
16+
emitter.on('start', (rawBlueprint, callback) ->
17+
logger.info('Beginning Dredd testing...')
18+
callback()
19+
)
1520

16-
emitter.on 'end', (callback) =>
21+
emitter.on('end', (callback) =>
1722
if @stats.tests > 0
1823
if @errors.length > 0
19-
@write "\n"
20-
logger.info "Displaying failed tests..."
24+
@write('\n')
25+
logger.info('Displaying failed tests...')
2126
for test in @errors
22-
logger.fail test.title + " duration: #{test.duration}ms"
23-
logger.fail test.message
24-
logger.request "\n" + prettifyResponse(test.request) + "\n"
25-
logger.expected "\n" + prettifyResponse(test.expected) + "\n"
26-
logger.actual "\n" + prettifyResponse(test.actual) + "\n\n"
27-
@write "\n"
28-
logger.complete "#{@stats.passes} passing, #{@stats.failures} failing, #{@stats.errors} errors, #{@stats.skipped} skipped"
29-
logger.complete "Tests took #{@stats.duration}ms"
27+
logger.fail(test.title + " duration: #{test.duration}ms")
28+
logger.fail(test.message)
29+
logger.request("\n" + prettifyResponse(test.request) + "\n")
30+
logger.expected("\n" + prettifyResponse(test.expected) + "\n")
31+
logger.actual("\n" + prettifyResponse(test.actual) + "\n\n")
32+
@write('\n')
33+
34+
logger.complete("""\
35+
#{@stats.passes} passing, #{@stats.failures} failing, \
36+
#{@stats.errors} errors, #{@stats.skipped} skipped
37+
""")
38+
logger.complete("Tests took #{@stats.duration}ms")
3039
callback()
40+
)
3141

32-
emitter.on 'test pass', (test) =>
33-
@write "."
42+
emitter.on('test pass', (test) =>
43+
@write('.')
44+
)
3445

35-
emitter.on 'test skip', (test) =>
36-
@write "-"
46+
emitter.on('test skip', (test) =>
47+
@write('-')
48+
)
3749

38-
emitter.on 'test fail', (test) =>
39-
@write "F"
40-
@errors.push test
50+
emitter.on('test fail', (test) =>
51+
@write('F')
52+
@errors.push(test)
53+
)
4154

42-
emitter.on 'test error', (error, test) =>
43-
@write "E"
55+
emitter.on('test error', (error, test) =>
56+
@write('E')
4457
test.message = "\nError: \n" + error + "\nStacktrace: \n" + error.stack + "\n"
45-
@errors.push test
58+
@errors.push(test)
59+
)
4660

4761
write: (str) ->
48-
process.stdout.write str
62+
process.stdout.write(str)
63+
64+
4965

5066
module.exports = DotReporter

test/unit/reporters/dot-reporter-test.coffee

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ describe 'DotReporter', () ->
4444
loggerStub.info.restore()
4545

4646
it 'should log that testing has begun', () ->
47-
emitter.emit 'start'
48-
assert.ok loggerStub.info.called
47+
emitter.emit 'start', '', () ->
48+
assert.ok loggerStub.info.called
4949

5050
describe 'when ending', () ->
5151

@@ -153,4 +153,3 @@ describe 'DotReporter', () ->
153153

154154
it 'should write an E', () ->
155155
assert.ok dotReporter.write.calledWith('E')
156-

0 commit comments

Comments
 (0)