-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
30 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { californiaArticleThreshold, getJSHeapSize } from './memory_test_utils' | ||
import { urbanstatsFixture } from './test_utils' | ||
|
||
urbanstatsFixture('california', '/article.html?longname=California%2C+USA&s=GczH23sVhzZkQid') | ||
|
||
test('under memory limit california', async (t) => { | ||
await t.expect(await getJSHeapSize(t)).lt(californiaArticleThreshold) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { getJSHeapSize, homePageThreshold } from './memory_test_utils' | ||
import { urbanstatsFixture } from './test_utils' | ||
|
||
urbanstatsFixture('home page', '/') | ||
|
||
test('under memory limit home page', async (t) => { | ||
await t.expect(await getJSHeapSize(t)).lt(homePageThreshold) | ||
}) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Since testcafe accumulates memory in the CI, each memory test must be run in its own test file | ||
export 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 | ||
} | ||
|
||
export const homePageThreshold = 35_000_000 | ||
export const compressedSearchIndexSize = 3_000_000 | ||
export const californiaArticleThreshold = 57_000_000 |