Skip to content

Commit c9f130e

Browse files
cola119targos
authored andcommitted
test: improve code coverage for performance_entry
PR-URL: #43434 Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Darshan Sen <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 061ed0e commit c9f130e

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

test/parallel/test-perf-hooks-resourcetiming.js

+50
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
const common = require('../common');
44
const assert = require('assert');
5+
const util = require('util');
56
const {
67
PerformanceObserver,
78
PerformanceEntry,
@@ -14,6 +15,7 @@ const {
1415

1516
assert(PerformanceObserver);
1617
assert(PerformanceEntry);
18+
assert.throws(() => new PerformanceEntry(), { code: 'ERR_ILLEGAL_CONSTRUCTOR' });
1719
assert(PerformanceResourceTiming);
1820
assert(clearResourceTimings);
1921
assert(markResourceTiming);
@@ -174,6 +176,54 @@ function createTimingInfo({
174176
encodedBodySize: 0,
175177
decodedBodySize: 0,
176178
});
179+
assert.strictEqual(util.inspect(performance.getEntries()), `[
180+
PerformanceResourceTiming {
181+
name: 'http://localhost:8080',
182+
entryType: 'resource',
183+
startTime: 0,
184+
duration: 0,
185+
initiatorType: 'fetch',
186+
nextHopProtocol: [],
187+
workerStart: 0,
188+
redirectStart: 0,
189+
redirectEnd: 0,
190+
fetchStart: 0,
191+
domainLookupStart: 0,
192+
domainLookupEnd: 0,
193+
connectStart: 0,
194+
connectEnd: 0,
195+
secureConnectionStart: 0,
196+
requestStart: 0,
197+
responseStart: 0,
198+
responseEnd: 0,
199+
transferSize: 0,
200+
encodedBodySize: 0,
201+
decodedBodySize: 0
202+
}
203+
]`);
204+
assert.strictEqual(util.inspect(resource), `PerformanceResourceTiming {
205+
name: 'http://localhost:8080',
206+
entryType: 'resource',
207+
startTime: 0,
208+
duration: 0,
209+
initiatorType: 'fetch',
210+
nextHopProtocol: [],
211+
workerStart: 0,
212+
redirectStart: 0,
213+
redirectEnd: 0,
214+
fetchStart: 0,
215+
domainLookupStart: 0,
216+
domainLookupEnd: 0,
217+
connectStart: 0,
218+
connectEnd: 0,
219+
secureConnectionStart: 0,
220+
requestStart: 0,
221+
responseStart: 0,
222+
responseEnd: 0,
223+
transferSize: 0,
224+
encodedBodySize: 0,
225+
decodedBodySize: 0
226+
}`);
177227

178228
assert(resource instanceof PerformanceEntry);
179229
assert(resource instanceof PerformanceResourceTiming);

0 commit comments

Comments
 (0)