Skip to content

Commit d807e3e

Browse files
committed
dont end the stream until cucumber says so
1 parent 211b68c commit d807e3e

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

src/formatter/html_formatter.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,30 @@ import Formatter, { IFormatterOptions } from '.'
22
import * as messages from '@cucumber/messages'
33
import resolvePkg from 'resolve-pkg'
44
import CucumberHtmlStream from '@cucumber/html-formatter'
5-
import { doesHaveValue } from '../value_checker'
65
import { finished } from 'stream'
76
import { promisify } from 'util'
87

98
export default class HtmlFormatter extends Formatter {
10-
private readonly _finished: Promise<void>
9+
private readonly _htmlStream: CucumberHtmlStream
1110
public static readonly documentation: string = 'Outputs HTML report'
1211

1312
constructor(options: IFormatterOptions) {
1413
super(options)
15-
const cucumberHtmlStream = new CucumberHtmlStream(
14+
this._htmlStream = new CucumberHtmlStream(
1615
resolvePkg('@cucumber/html-formatter', { cwd: __dirname }) +
1716
'/dist/main.css',
1817
resolvePkg('@cucumber/html-formatter', { cwd: __dirname }) +
1918
'/dist/main.js'
2019
)
2120
options.eventBroadcaster.on('envelope', (envelope: messages.Envelope) => {
22-
cucumberHtmlStream.write(envelope)
23-
if (doesHaveValue(envelope.testRunFinished)) {
24-
cucumberHtmlStream.end()
25-
}
21+
this._htmlStream.write(envelope)
2622
})
27-
cucumberHtmlStream.on('data', (chunk) => this.log(chunk))
28-
this._finished = promisify(finished)(cucumberHtmlStream)
23+
this._htmlStream.on('data', (chunk) => this.log(chunk))
2924
}
3025

3126
async finished(): Promise<void> {
32-
await this._finished
27+
this._htmlStream.end()
28+
await promisify(finished)(this._htmlStream)
3329
await super.finished()
3430
}
3531
}

0 commit comments

Comments
 (0)