Skip to content

Commit

Permalink
test: improve code coverage for performance_entry
Browse files Browse the repository at this point in the history
PR-URL: #43434
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
cola119 authored and targos committed Jul 12, 2022
1 parent 061ed0e commit c9f130e
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions test/parallel/test-perf-hooks-resourcetiming.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

const common = require('../common');
const assert = require('assert');
const util = require('util');
const {
PerformanceObserver,
PerformanceEntry,
Expand All @@ -14,6 +15,7 @@ const {

assert(PerformanceObserver);
assert(PerformanceEntry);
assert.throws(() => new PerformanceEntry(), { code: 'ERR_ILLEGAL_CONSTRUCTOR' });
assert(PerformanceResourceTiming);
assert(clearResourceTimings);
assert(markResourceTiming);
Expand Down Expand Up @@ -174,6 +176,54 @@ function createTimingInfo({
encodedBodySize: 0,
decodedBodySize: 0,
});
assert.strictEqual(util.inspect(performance.getEntries()), `[
PerformanceResourceTiming {
name: 'http://localhost:8080',
entryType: 'resource',
startTime: 0,
duration: 0,
initiatorType: 'fetch',
nextHopProtocol: [],
workerStart: 0,
redirectStart: 0,
redirectEnd: 0,
fetchStart: 0,
domainLookupStart: 0,
domainLookupEnd: 0,
connectStart: 0,
connectEnd: 0,
secureConnectionStart: 0,
requestStart: 0,
responseStart: 0,
responseEnd: 0,
transferSize: 0,
encodedBodySize: 0,
decodedBodySize: 0
}
]`);
assert.strictEqual(util.inspect(resource), `PerformanceResourceTiming {
name: 'http://localhost:8080',
entryType: 'resource',
startTime: 0,
duration: 0,
initiatorType: 'fetch',
nextHopProtocol: [],
workerStart: 0,
redirectStart: 0,
redirectEnd: 0,
fetchStart: 0,
domainLookupStart: 0,
domainLookupEnd: 0,
connectStart: 0,
connectEnd: 0,
secureConnectionStart: 0,
requestStart: 0,
responseStart: 0,
responseEnd: 0,
transferSize: 0,
encodedBodySize: 0,
decodedBodySize: 0
}`);

assert(resource instanceof PerformanceEntry);
assert(resource instanceof PerformanceResourceTiming);
Expand Down

0 comments on commit c9f130e

Please sign in to comment.