Public
Edited
May 9, 2023
Insert cell
Insert cell
viewof raw = Inputs.textarea({ placeholder: "Paste failed tests here" })
Insert cell
html`${tests_html}`
Insert cell
tests_html = {
let bits = [];
groups.forEach((group) => {
bits.push(`<h3>${group.name} - ${group.total}</h3>`);
group.files.forEach((file) => {
bits.push(`<h4>${file.name} (${file.tests.length})</h4>`);
file.tests.forEach((test) => {
bits.push(
`${escapeHtml(
test.test
)}<br>&nbsp;&nbsp;&nbsp;<span style="font-size: 0.8em">${escapeHtml(
test.rest
)}</span><br>`
);
});
});
});
return bits.join("");
}
Insert cell
lines = raw.split(/\n/g).filter((e) => e.trim())
Insert cell
function parse(line) {
let [type_, where, ignore, ...rest] = line.split(/ /g);
let [path, test] = where.split("::");
return { type_, path, test, rest: rest.join(" ") };
}
Insert cell
parsed = lines.map(parse)
Insert cell
Inputs.table(parsed)
Insert cell
html`<textarea>${JSON.stringify(parsed.slice(0, 3))}</textarea>`
Insert cell
function groupBy(arr, key) {
const groupedData = {};
arr.forEach((item) => {
const groupKey = item[key];
if (!groupedData[groupKey]) {
groupedData[groupKey] = [];
}
groupedData[groupKey].push(item);
});
const result = Object.entries(groupedData).map(([name, tests]) => ({
name,
tests
}));
return result;
}
Insert cell
groups = groupBy(parsed, "type_").map((o) => ({
name: o.name,
total: o.tests.length,
files: groupBy(o.tests, "path").sort(
(a, b) => b.tests.length - a.tests.length
)
}))
Insert cell
function escapeHtml(unsafe) {
if (!unsafe) {
return "";
}
return unsafe
.replace(/&/g, "&amp;")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")
.replace(/"/g, "&quot;")
.replace(/'/g, "&#039;");
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more