MCPcopy Index your code
hub / github.com/developit/htm / test

Function test

test/__d8.mjs:26–49  ·  view source on GitHub ↗
(name, fn, path)

Source from the content-addressed store, hash-verified

24 stack.pop();
25 },
26 async test(name, fn, path) {
27 let stackBefore = stack;
28 stack = path.concat(name);
29 logBuffer = [];
30 await new Promise(resolve => {
31 let calls = 0;
32 const done = () => {
33 if (calls++) throw Error(`Callback called multiple times\n\t${name}`);
34 log('INFO', `✅ ${name}`);
35 resolve();
36 };
37 Promise.resolve(done)
38 .then(fn)
39 .then(() => calls || done())
40 .catch(err => {
41 log('ERROR', `🚨 ${name}`);
42 log('ERROR', '\t' + String(err.stack || err.message || err));
43 resolve();
44 });
45 });
46 for (let i=0; i<logBuffer.length; i++) log(...logBuffer[i]);
47 logBuffer = undefined;
48 stack = stackBefore;
49 }
50};
51
52

Callers 6

index.test.mjsFile · 0.85
preact.test.mjsFile · 0.85
perf.test.mjsFile · 0.85
babel.test.mjsFile · 0.85

Calls 2

doneFunction · 0.85
logFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…