Public
Edited
Jun 17, 2023
Fork of Test
Importers
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
test('numbers are equal', t => {
t.equal(1, 1);
})
Insert cell
test = {
const tape = await require(await FileAttachment("tape-4.12.js").url());

return (name, fn, options) => {
const output = html`<pre />`
const passed = html`<style>.observablehq--passed {color: #009C28} .observablehq--passed:before {background-color: #009C28}</style><div class="observablehq observablehq--passed">${name}</div>`
const display = html`<div class="observablehq observablehq--error">${output}</div>`

let test = tape.createHarness();
let stream = test.createStream();

const runner = t => {
try {
fn(t);
} catch(err) {
t.error(err);
}
t.end();
};
test(name, runner, options);
return Generators.observe(change => {
let failed = false;
stream.on('data', d => {
output.appendChild(document.createTextNode(d));
if (d.startsWith('not ok')) {
failed = true;
}
});

stream.on('end', () => {
if (failed) {
// display.style.background = '#FFDFDF';
change(display);
} else {
change(passed);
}
});
});
}
}
Insert cell
tape = require('tape@5.6.3/index.js').catch(() => window)
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