-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PERF-813 Capture diagnostic details (#63)
* Assert expected diagnostic detail * Capture and report diagnostic details * fix: ?? operator is lower precedence than >= ! * Consolidate diagnostic detail in `lastVisualUpdate` key * lastVisualUpdate -> lastVisibleChange * Document new diagnostic detail in README Co-authored-by: Andrew Hyndman <ahyndman@dropbox.com>
- Loading branch information
Showing
7 changed files
with
130 additions
and
17 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
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
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
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,9 @@ | ||
<head> | ||
<script src="/dist/index.min.js"></script> | ||
<script src="/analytics.js"></script> | ||
</head> | ||
|
||
<body> | ||
<h1 id="h1">Hello world!</h1> | ||
<img src="/150.png?delay=500" /> | ||
</body> |
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,39 @@ | ||
import {test, expect} from '@playwright/test'; | ||
|
||
import {FUDGE} from '../../util/constants'; | ||
import {getEntries} from '../../util/entries'; | ||
|
||
const PAGELOAD_DELAY = 200; | ||
const IMAGE_DELAY = 500; | ||
|
||
test.describe('TTVC', () => { | ||
test('output reports timing data', async ({page}) => { | ||
await page.goto(`/test/output1?delay=${PAGELOAD_DELAY}`, { | ||
waitUntil: 'networkidle', | ||
}); | ||
|
||
const entries = await getEntries(page); | ||
|
||
expect(entries.length).toBe(1); | ||
expect(entries[0].duration).toBeGreaterThanOrEqual(PAGELOAD_DELAY + IMAGE_DELAY); | ||
expect(entries[0].duration).toBeLessThanOrEqual(PAGELOAD_DELAY + IMAGE_DELAY + FUDGE); | ||
expect(entries[0].start).toBeDefined(); | ||
expect(entries[0].end).toBeDefined(); | ||
}); | ||
|
||
test('output includes detail', async ({page}) => { | ||
await page.goto(`/test/output1?delay=${PAGELOAD_DELAY}`, { | ||
waitUntil: 'networkidle', | ||
}); | ||
|
||
const entries = await getEntries(page); | ||
|
||
expect(entries.length).toBe(1); | ||
expect(entries[0].detail).toBeDefined(); | ||
expect(entries[0].detail.didNetworkTimeOut).toBe(false); | ||
const isImageElement = await page.evaluate(() => { | ||
return window.entries[0].detail.lastVisibleChange instanceof HTMLImageElement; | ||
}); | ||
expect(isImageElement).toBe(true); | ||
}); | ||
}); |
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 @@ | ||
<head> | ||
<script src="/dist/index.min.js"></script> | ||
<script src="/analytics.js"></script> | ||
</head> | ||
|
||
<body> | ||
<h1 id="h1">Hello world!</h1> | ||
</body> |
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,39 @@ | ||
import {test, expect} from '@playwright/test'; | ||
|
||
import {FUDGE} from '../../util/constants'; | ||
import {getEntries} from '../../util/entries'; | ||
|
||
const PAGELOAD_DELAY = 200; | ||
|
||
test.describe('TTVC', () => { | ||
test('output reports timing data', async ({page}) => { | ||
await page.goto(`/test/output2?delay=${PAGELOAD_DELAY}`, { | ||
waitUntil: 'networkidle', | ||
}); | ||
|
||
const entries = await getEntries(page); | ||
|
||
expect(entries.length).toBe(1); | ||
expect(entries[0].duration).toBeGreaterThanOrEqual(PAGELOAD_DELAY); | ||
expect(entries[0].duration).toBeLessThanOrEqual(PAGELOAD_DELAY + FUDGE); | ||
expect(entries[0].start).toBeDefined(); | ||
expect(entries[0].end).toBeDefined(); | ||
}); | ||
|
||
test('output includes detail', async ({page}) => { | ||
await page.goto(`/test/output2?delay=${PAGELOAD_DELAY}`, { | ||
waitUntil: 'networkidle', | ||
}); | ||
|
||
const entries = await getEntries(page); | ||
|
||
expect(entries.length).toBe(1); | ||
expect(entries[0].detail).toBeDefined(); | ||
expect(entries[0].detail.didNetworkTimeOut).toBe(false); | ||
|
||
const isMutationRecord = await page.evaluate(() => { | ||
return window.entries[0].detail.lastVisibleChange instanceof MutationRecord; | ||
}); | ||
expect(isMutationRecord).toBe(true); | ||
}); | ||
}); |