@@ -12,6 +12,9 @@ import { initDenoDom } from "../src/core/deno-dom.ts";
1212import { cleanupLogger , initializeLogger } from "../src/core/log.ts" ;
1313import { quarto } from "../src/quarto.ts" ;
1414import { join } from "path/mod.ts" ;
15+ import * as colors from "fmt/colors.ts" ;
16+ import { isInteractiveTerminal } from "../src/core/platform.ts" ;
17+ import { runningInCI } from "../src/core/ci-info.ts" ;
1518
1619export interface TestDescriptor {
1720 // The name of the test
@@ -111,7 +114,7 @@ export function test(test: TestDescriptor) {
111114
112115 Deno . test ( {
113116 name : testName ,
114- async fn ( ) {
117+ async fn ( context ) {
115118 await initDenoDom ( ) ;
116119 const runTest = ! test . context . prereq || await test . context . prereq ( ) ;
117120 if ( runTest ) {
@@ -162,15 +165,39 @@ export function test(test: TestDescriptor) {
162165 }
163166 }
164167 } catch ( ex ) {
168+ const isInteractive = isInteractiveTerminal ( ) && ! runningInCI ( ) ;
169+ const border = "-" . repeat ( 80 ) ;
170+ const coloredName = isInteractive
171+ ? colors . brightGreen ( colors . italic ( testName ) )
172+ : testName ;
173+ const origin = context . origin . replace ( "file://" , "" ) ;
174+ const coloredOrigin = isInteractive
175+ ? colors . brightGreen ( origin )
176+ : origin ;
177+
165178 const logMessages = logOutput ( log ) ;
179+ const output : string [ ] = [
180+ "" ,
181+ "" ,
182+ border ,
183+ coloredName ,
184+ coloredOrigin ,
185+ "" ,
186+ ex . message ,
187+ ex . stack ,
188+ "" ,
189+ ] ;
190+
166191 if ( logMessages && logMessages . length > 0 ) {
167- const errorTxts = logMessages . map ( ( msg ) => msg . msg ) ;
168- fail (
169- `\n---------------------------------------------\n${ ex . message } \n${ ex . stack } \n\nTEST OUTPUT:\n${ errorTxts } ----------------------------------------------` ,
170- ) ;
171- } else {
172- fail ( `${ ex . message } \n${ ex . stack } ` ) ;
192+ output . push ( "OUTPUT:" ) ;
193+ logMessages . forEach ( ( out ) => {
194+ const parts = out . msg . split ( "\n" ) ;
195+ parts . forEach ( ( part ) => {
196+ output . push ( " " + part ) ;
197+ } ) ;
198+ } ) ;
173199 }
200+ fail ( output . join ( "\n" ) ) ;
174201 } finally {
175202 Deno . removeSync ( log ) ;
176203 await cleanupLogOnce ( ) ;
0 commit comments