@@ -20,7 +20,7 @@ interface TestAppPaths {
2020
2121interface TestAppOutput {
2222 bookSpecs : PkBookSpec [ ] ;
23- consoleLog : string [ ] ;
23+ consoleLog : string ;
2424}
2525
2626const testAppsDir = path . join ( 'convert' , 'test' , 'characterization' , 'test_apps' ) ;
@@ -145,10 +145,14 @@ function assertSetsEqual(actual: any[], expected: any[]) {
145145function listenForOutput ( ) : TestAppOutput {
146146 const output : TestAppOutput = {
147147 bookSpecs : [ ] ,
148- consoleLog : [ ]
148+ consoleLog : ''
149149 } ;
150150 PkTestLogger . instance ( ) . setOnBookCreated ( ( spec ) => output . bookSpecs . push ( spec ) ) ;
151- console . log = ( msg ) => output . consoleLog . push ( msg ) ;
151+ console . log = ( msg ) => ( output . consoleLog += msg + '\n' ) ;
152+ process . stdout . write = ( msg ) => {
153+ output . consoleLog += msg . toString ( ) ;
154+ return true ;
155+ } ;
152156 return output ;
153157}
154158
@@ -171,19 +175,13 @@ async function checkConsoleLog(output: TestAppOutput, paths: TestAppPaths) {
171175 if ( existsSync ( paths . consoleLog ) ) {
172176 await assertConsoleLogsEqual ( paths , output ) ;
173177 } else {
174- await writeConsoleLog ( output , paths ) ;
178+ await writeFile ( paths . consoleLog , output . consoleLog ) ;
175179 }
176180}
177181
178- async function writeConsoleLog ( output : TestAppOutput , paths : TestAppPaths ) {
179- const logs = output . consoleLog . join ( `\n` ) ;
180- await writeFile ( paths . consoleLog , logs ) ;
181- }
182-
183182async function assertConsoleLogsEqual ( paths : TestAppPaths , output : TestAppOutput ) {
184- const logs = output . consoleLog . join ( `\n` ) ;
185183 const expected = await readFile ( paths . consoleLog ) ;
186- expect ( logs ) . toBe ( expected . toString ( ) ) ;
184+ expect ( output . consoleLog ) . toBe ( expected . toString ( ) ) ;
187185}
188186
189187async function checkBookSpecs ( output : TestAppOutput , paths : TestAppPaths ) {
0 commit comments