Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorYash Ladha <yashladhapankajladha123@gmail.com>2021-03-16 19:45:02 +0300
committerJames M Snell <jasnell@gmail.com>2021-04-30 23:28:27 +0300
commit93f0b4d35bf72a1119b8a5bfea932b85faa1a4a6 (patch)
treeb50d379518b06a75ddaef611d347e17a1b9fe02e /test
parent5bfb6f0564403093c03c30112763e5fa1bb24df5 (diff)
perf_hooks: add toJSON to performance class
Added toJSON method to the InternalPerformance class as per the convention followed in other performance classes and per the spec: https://www.w3.org/TR/hr-time/#tojson-method Fixes: https://github.com/nodejs/node/issues/37623 PR-URL: https://github.com/nodejs/node/pull/37771 Fixes: https://github.com/nodejs/node/issues/37623 Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-tojson-perf_hooks.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/parallel/test-tojson-perf_hooks.js b/test/parallel/test-tojson-perf_hooks.js
new file mode 100644
index 00000000000..2a716fc4478
--- /dev/null
+++ b/test/parallel/test-tojson-perf_hooks.js
@@ -0,0 +1,14 @@
+'use strict';
+
+require('../common');
+const assert = require('assert');
+const { performance } = require('perf_hooks');
+
+// Test toJSON for performance object
+{
+ assert.strictEqual(typeof performance.toJSON, 'function');
+ const jsonObject = performance.toJSON();
+ assert.strictEqual(typeof jsonObject, 'object');
+ assert.strictEqual(jsonObject.timeOrigin, performance.timeOrigin);
+ assert.strictEqual(typeof jsonObject.nodeTiming, 'object');
+}