Skip to content

Commit

Permalink
Memory tests (#860)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukebrody authored Jan 6, 2025
1 parent 51436d6 commit 44db313
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions react/test/memory_test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { urbanstatsFixture } from './test_utils'

async function getJSHeapSize(t: TestController): Promise<number> {
await t.wait(1000) // Wait for page to load
const cdpSession = await t.getCurrentCDPSession()
await cdpSession.HeapProfiler.collectGarbage()
await t.wait(1000) // Wait for garbage collect
const bytesUsed = await t.eval(() => (performance as unknown as { memory: { usedJSHeapSize: number } }).memory.usedJSHeapSize) as number
console.warn(`Bytes used: ${bytesUsed}`)
return bytesUsed
}

urbanstatsFixture('home page', '/')

test('under memory limit home page', async (t) => {
await t.expect(await getJSHeapSize(t)).lt(35_000_000)
})

urbanstatsFixture('california', '/article.html?longname=California%2C+USA&s=GczH23sVhzZkQid')

test('under memory limit california', async (t) => {
await t.expect(await getJSHeapSize(t)).lt(66_000_000)
})

0 comments on commit 44db313

Please sign in to comment.