@@ -37,18 +37,19 @@ window.debug = function (data) {
3737 send({ type: "debug", data });
3838};
3939
40+ let indents = 0,
41+ passed = 0,
42+ failed = 0,
43+ aborted = false;
44+
4045// Inherit the default test settings from Zotero
4146function Reporter(runner) {
42- var indents = 0,
43- passed = 0,
44- failed = 0,
45- aborted = false;
46-
4747 function indent() {
4848 return " ".repeat(indents);
4949 }
5050
5151 function dump(str) {
52+ // console.log(str)
5253 // const p = document.createElement("p")
5354 // p.textContent = str
5455 // document.querySelector("#mocha").append(p)
@@ -57,30 +58,30 @@ function Reporter(runner) {
5758
5859 runner.on("start", async function () {
5960 console.log("start")
60- await send({ type: "start" });
61+ await send({ type: "start", data: { indents } });
6162 });
6263
6364 runner.on("suite", async function (suite) {
6465 console.log("suite", suite)
6566 indents++;
6667 const str = indent() + suite.title + "\\n";
6768 dump(str);
68- await send({ type: "suite", data: { title: suite.title, root: suite.root } });
69+ await send({ type: "suite", data: { title: suite.title, root: suite.root, indents } });
6970 });
7071
7172 runner.on("suite end", async function (suite) {
7273 console.log("suite end", suite)
7374 indents--;
7475 const str = indents === 1 ? "\\n" : "";
7576 dump(str);
76- await send({ type: "suite end", data: { title: suite.title, root: suite.root } });
77+ await send({ type: "suite end", data: { title: suite.title, root: suite.root, indents } });
7778 });
7879
7980 runner.on("pending", async function (test) {
8081 console.log("pending", test)
8182 const str = indent() + "pending -" + test.title + "\\n";
8283 dump(str);
83- await send({ type: "pending", data: { title: test.title, fulltest: test.fullTitle(), duration: test.duration } });
84+ await send({ type: "pending", data: { title: test.title, fulltest: test.fullTitle(), duration: test.duration, indents: indents + 1 } });
8485 });
8586
8687 runner.on("pass", async function (test) {
@@ -92,7 +93,7 @@ function Reporter(runner) {
9293 }
9394 str += "\\n";
9495 dump(str);
95- await send({ type: "pass", data: { title: test.title, fulltest: test.fullTitle(), duration: test.duration } });
96+ await send({ type: "pass", data: { title: test.title, fulltest: test.fullTitle(), duration: test.duration, indents: indents + 1 } });
9697
9798 });
9899
@@ -121,7 +122,7 @@ function Reporter(runner) {
121122 "\\n\\n";
122123 dump(str);
123124
124- await send({ type: "fail", data: { title: test.title, fulltest: test.fullTitle(), duration: test.duration, error } });
125+ await send({ type: "fail", data: { title: test.title, fulltest: test.fullTitle(), duration: test.duration, error, indents: indents + 1 } });
125126
126127 });
127128
@@ -138,7 +139,7 @@ function Reporter(runner) {
138139
139140 await send({
140141 type: "end",
141- data: { passed: passed, failed: failed, aborted: aborted, str },
142+ data: { passed: passed, failed: failed, aborted: aborted, str, indents },
142143 });
143144
144145 // Must exit on Zotero side, otherwise the exit code will not be 0 and CI will fail
0 commit comments