Skip to main content

Hooking up Jest

Putting all the pieces together, the following code listing shows the top-level test implementation. These tests are written to use the Jest testing framework.

Notice the use of the observeTraceTests variable (from the previous Test cases page) enables executing each test case without changing the core logic.

describe("dereference (integration)", () => {
describe("changing pointer values over the course of a trace", () => {
for (const [name, test] of Object.entries(observeTraceTests)) {
const { expectedValues, ...options } = test;

describe(`example pointer: ${name}`, () => {
it("resolves to values containing the expected sequence", async () => {
const observedValues =
await observeTrace(options as Parameters<typeof observeTrace>[0]);

expect(observedValues)
.toEqual(expect.arrayContaining(expectedValues));
});
});
}
});
});