@@ -15,6 +15,7 @@ import {
1515import { replTests } from "@my-code/runtime/tests/repl" ;
1616import { fileExecutionTests } from "@my-code/runtime/tests/fileExecution" ;
1717import { useRuntimeAll } from "@my-code/runtime/context" ;
18+ import { captureException } from "@sentry/nextjs" ;
1819
1920import main_py from "./samples/main.py?raw" ;
2021import main_rb from "./samples/main.rb?raw" ;
@@ -210,6 +211,10 @@ function AnsiColorSample() {
210211 ) ;
211212}
212213
214+ function handleRuntimeError ( error : unknown ) {
215+ captureException ( error ) ;
216+ }
217+
213218function MochaTest ( ) {
214219 const runtimeAll = useRuntimeAll ( ) ;
215220 const runtimeRef = useRef ( runtimeAll ) ;
@@ -233,7 +238,7 @@ function MochaTest() {
233238 mocha . setup ( "bdd" ) ;
234239
235240 for ( const lang of Object . keys ( runtimeRef . current ) as RuntimeLang [ ] ) {
236- runtimeRef . current [ lang ] . init ?.( ) ;
241+ runtimeRef . current [ lang ] . init ?.( handleRuntimeError ) ;
237242
238243 describe ( `${ lang } Runtime` , function ( ) {
239244 this . timeout ( RUNTIME_TIMEOUTS [ lang ] ) ;
@@ -270,6 +275,14 @@ function MochaTest() {
270275 }
271276
272277 const runner = mocha . run ( ) ;
278+ runner . on ( "fail" , ( test , err : unknown ) => {
279+ console . error ( err , {
280+ extra : {
281+ fullTitle : test . fullTitle ( ) ,
282+ ...( typeof err === "object" && err ? err : { } ) ,
283+ } ,
284+ } ) ;
285+ } ) ;
273286 runner . on ( "end" , ( ) => {
274287 setMochaState ( "finished" ) ;
275288 } ) ;
0 commit comments