Skip to content

Commit 99c4ca7

Browse files
committed
テストのエラーもsentryに送る
1 parent e270b49 commit 99c4ca7

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

app/terminal/page.tsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
import { replTests } from "@my-code/runtime/tests/repl";
1616
import { fileExecutionTests } from "@my-code/runtime/tests/fileExecution";
1717
import { useRuntimeAll } from "@my-code/runtime/context";
18+
import { captureException } from "@sentry/nextjs";
1819

1920
import main_py from "./samples/main.py?raw";
2021
import 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+
213218
function 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

Comments
 (0)