Public
Edited
Nov 10, 2023
Fork of unittest
Importers
Insert cell
Insert cell
test('Addition', () => {
expect(1 + 2).toBe(3)
})
Insert cell
test('Array.push() and pop()', () => {
const array = [1, 2, 3]
// push
array.push(4)
expect(array).toStrictEqual([1, 2, 3, 4])
// pop
expect(array.pop()).toBe(4)
expect(array).toStrictEqual([1, 2, 3])
})
Insert cell
Insert cell
function fixture() {
return [1, 2, 3]
}
Insert cell
test('Addition with pre-defined data', () => {
const data = fixture()
expect(data.reduce((a, b) => a + b)).toBe(1 + 2 + 3)
})
Insert cell
describe("bar", () => {
test("foo1", () => {});
test("foo2", () => {
expect(1).toBe(1);
});
})
Insert cell
Insert cell
function describe(title, f) {
window.describe_results = [];
f();
return html`<div style="color:green;" >${title}</div>
<span>${window.describe_results}</span>`;
}
Insert cell
test = (title, f) => {
f();

const r = html`<div style="color:green;" >✓ ${
title || "Test passing "
}</div>`;

if (window.describe_results) {
window.describe_results.push(r);
}
return r;
}
Insert cell
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