Skip to content

Commit 86c34a5

Browse files
authored
Allow tests to leak (#134)
* Allow tests to leak * Move the leaks test where expectations are known
1 parent eee72fe commit 86c34a5

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

memory-leaks/tests/cell.test.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ describe("# Cell memory leaks", () => {
77
await testScenario(addScenario, {
88
expectations: [
99
// Code cell
10-
{ objects: 980, collections: 18 },
10+
{ leak: true, objects: 980, collections: 18 },
1111
// Markdown cell
12-
{ objects: 656, collections: 28 },
12+
{ leak: true, objects: 656, collections: 28 },
1313
// Raw cell
14-
{ objects: 548, collections: 28 },
14+
{ leak: true, objects: 548, collections: 28 },
1515
],
1616
});
1717
});

memory-leaks/tests/notebook.test.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as notebookScenario from "./notebook.mjs";
44
describe("# Notebook memory leaks", () => {
55
it("Opening a notebook", async () => {
66
await testScenario(notebookScenario, {
7-
expectations: [{ collections: 8, objects: 463 }],
7+
expectations: [{ leak: true, collections: 8, objects: 463 }],
88
});
99
});
1010
});

memory-leaks/tests/utils.mjs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,13 @@ function expectNoLeaks(results, defaultValues = []) {
2525
console.log(formatResultAsMarkdown(test));
2626
});
2727

28-
expect(
29-
results.map((test) => test.result.leaks.detected).includes(true)
30-
).to.equal(false);
31-
3228
results.forEach((test, idx) => {
3329
const expectations = defaultValues[idx] ?? {};
30+
31+
expect(
32+
test.result.leaks.detected
33+
).to.equal(expectations.leak ?? false);
34+
3435
expect(
3536
test.result.leaks.objects
3637
.map((obj) => obj.countDeltaPerIteration)

0 commit comments

Comments
 (0)