@@ -2,34 +2,30 @@ import Formatter, { IFormatterOptions } from '.'
2
2
import * as messages from '@cucumber/messages'
3
3
import resolvePkg from 'resolve-pkg'
4
4
import CucumberHtmlStream from '@cucumber/html-formatter'
5
- import { doesHaveValue } from '../value_checker'
6
5
import { finished } from 'stream'
7
6
import { promisify } from 'util'
8
7
9
8
export default class HtmlFormatter extends Formatter {
10
- private readonly _finished : Promise < void >
9
+ private readonly _htmlStream : CucumberHtmlStream
11
10
public static readonly documentation : string = 'Outputs HTML report'
12
11
13
12
constructor ( options : IFormatterOptions ) {
14
13
super ( options )
15
- const cucumberHtmlStream = new CucumberHtmlStream (
14
+ this . _htmlStream = new CucumberHtmlStream (
16
15
resolvePkg ( '@cucumber/html-formatter' , { cwd : __dirname } ) +
17
16
'/dist/main.css' ,
18
17
resolvePkg ( '@cucumber/html-formatter' , { cwd : __dirname } ) +
19
18
'/dist/main.js'
20
19
)
21
20
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 )
26
22
} )
27
- cucumberHtmlStream . on ( 'data' , ( chunk ) => this . log ( chunk ) )
28
- this . _finished = promisify ( finished ) ( cucumberHtmlStream )
23
+ this . _htmlStream . on ( 'data' , ( chunk ) => this . log ( chunk ) )
29
24
}
30
25
31
26
async finished ( ) : Promise < void > {
32
- await this . _finished
27
+ this . _htmlStream . end ( )
28
+ await promisify ( finished ) ( this . _htmlStream )
33
29
await super . finished ( )
34
30
}
35
31
}
0 commit comments