Skip to content

Commit

Permalink
Add test to capture early hints
Browse files Browse the repository at this point in the history
  • Loading branch information
benschwarz committed Jul 4, 2024
1 parent 46907b7 commit cb0d94b
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion test/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const PERFLOGSPATH = path.resolve(__dirname, 'perflogs');
*/
function validateConnectionOverlap(t, entries) {
const entriesByConnection = entries
.filter(entry => !['h2', 'spdy/3.1'].includes(entry.response.httpVersion))
.filter(entry => !['h3', 'h2', 'spdy/3.1'].includes(entry.response.httpVersion))
.filter(entry => !(entry.cache || {}).beforeRequest)
.reduce((entries, entry) => {
const e = entries.get(entry.connection) || [];
Expand Down Expand Up @@ -196,6 +196,17 @@ test('Includes pushed assets', t => {
});
});

test('Includes early hints requests', t => {
const perflogPath = perflog('early-hints.json');
return parsePerflog(perflogPath)
.then(har => {
const earlyHints = har.log.entries.filter(e => e.response.fromEarlyHints);
t.is(earlyHints.length, 11);

return har;
});
})

test('Includes response bodies', t => {
const perflogPath = perflog('www.sitepeed.io.chrome66.json');
return parsePerflog(perflogPath, { includeTextFromResponseBody: true })
Expand Down

0 comments on commit cb0d94b

Please sign in to comment.