MCPcopy Index your code
hub / github.com/scriptscat/scriptcat / runAll

Function runAll

example/tests/gm_xhr_test.js:1985–2015  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1983
1984 // ---------- Runner ----------
1985 async function runAll() {
1986 // reset counts
1987 state.pass = state.fail = state.skip = 0;
1988 setCounts(0, 0, 0);
1989 const names = tests.map((t) => t.name);
1990 setQueue(names.slice());
1991 logLine(`<b>Starting GM_xmlhttpRequest test suite</b> — ${new Date().toLocaleString()}`);
1992
1993 for (let i = 0; i < tests.length; i++) {
1994 const t = tests[i];
1995 const tName = `${t.useFetch ? "[fetch]" : "[xhr]"} ${t.name}`;
1996 const title = `• ${tName}`;
1997 const t0 = performance.now();
1998 setStatus(`running (${i + 1}/${tests.length}): ${tName}`);
1999 try {
2000 logLine(`▶️ <b>${escapeHtml(tName)}</b> (queued: ${tests.length - i - 1} remaining)`);
2001 await t.run(t.useFetch ? true : false);
2002 pass(`${title} (${fmtMs(performance.now() - t0)})`);
2003 } catch (e) {
2004 console.error(e);
2005 const extra = e && e.stack ? prettyStack(e, { maxLines: 4 }) : null;
2006 fail(`${title} (${fmtMs(performance.now() - t0)})`, [e?.message, extra].filter(Boolean).join("\n"));
2007 } finally {
2008 // update pending list
2009 setQueue(names.slice(i + 1));
2010 }
2011 }
2012
2013 setStatus("done");
2014 logLine(`<b>Done.</b> Summary — ✅ ${state.pass} ❌ ${state.fail} ⏳ ${state.skip}`);
2015 }
2016
2017 function fmtMs(ms) {
2018 return ms < 1000 ? `${ms | 0}ms` : `${(ms / 1000).toFixed(2)}s`;

Callers 1

gm_xhr_test.jsFile · 0.70

Calls 11

prettyStackFunction · 0.85
errorMethod · 0.80
setCountsFunction · 0.70
setQueueFunction · 0.70
logLineFunction · 0.70
setStatusFunction · 0.70
escapeHtmlFunction · 0.70
passFunction · 0.70
fmtMsFunction · 0.70
failFunction · 0.70
sliceMethod · 0.45

Tested by

no test coverage detected