Skip to content

Commit 482ea61

Browse files
Use a fixture
1 parent 46d0865 commit 482ea61

2 files changed

Lines changed: 23 additions & 25 deletions

File tree

tests/fixtures/example.heapsnapshot

Lines changed: 8 additions & 0 deletions
Large diffs are not rendered by default.

tests/tools/memory.test.ts

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -40,36 +40,26 @@ describe('memory', () => {
4040
});
4141
});
4242

43-
describe('explore_memory_snapshot', () => {
43+
describe('load_memory_snapshot', () => {
4444
it('with default options', async () => {
4545
await withMcpContext(async (response, context) => {
46-
const filePath = join(tmpdir(), 'test-explore.heapsnapshot');
47-
try {
48-
await takeMemorySnapshot.handler(
49-
{params: {filePath}, page: context.getSelectedMcpPage()},
50-
response,
51-
context,
52-
);
46+
const filePath = join(process.cwd(), 'tests/fixtures/example.heapsnapshot');
47+
48+
assert.ok(existsSync(filePath), `Fixture not found at ${filePath}`);
5349

54-
await exploreMemorySnapshot.handler(
55-
{params: {filePath}},
56-
response,
57-
context,
58-
);
50+
await exploreMemorySnapshot.handler(
51+
{params: {filePath}},
52+
response,
53+
context,
54+
);
5955

60-
assert.equal(
61-
response.responseLines.at(0),
62-
`Heap snapshot saved to ${filePath}`,
63-
);
64-
assert.ok(existsSync(filePath));
56+
// Call handle to trigger formatting (similar to network tests)
57+
const responseData = await response.handle(exploreMemorySnapshot.name, context);
58+
const output = responseData.content.map(c => (c.type === 'text' ? c.text : '')).join('\n');
6559

66-
// Check if response contains Statistics or Static Data
67-
const output = response.responseLines.join('\n');
68-
assert.ok(output.includes('Statistics:'));
69-
assert.ok(output.includes('Static Data:'));
70-
} finally {
71-
await rm(filePath, {force: true});
72-
}
60+
// Check if response contains Statistics or Static Data
61+
assert.ok(output.includes('Statistics:'));
62+
assert.ok(output.includes('Static Data:'));
7363
});
7464
});
7565
});

0 commit comments

Comments
 (0)