-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: improve
worker_threads
coverage
PR-URL: #41818 Refs: https://coverage.nodejs.org/coverage-7123a00b03a90862/lib/internal/worker.js.html#L412 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: James M Snell <[email protected]>
- Loading branch information
1 parent
3b338cf
commit ba5b5ac
Showing
2 changed files
with
21 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const { Worker } = require('worker_threads'); | ||
const { once } = require('events'); | ||
|
||
// Ensure that worker.getHeapSnapshot() returns a valid JSON | ||
(async () => { | ||
const worker = new Worker('setInterval(() => {}, 1000);', { eval: true }); | ||
await once(worker, 'online'); | ||
const stream = await worker.getHeapSnapshot(); | ||
assert.ok(JSON.parse(stream.read())); | ||
|
||
await worker.terminate(); | ||
})().then(common.mustCall()); |