-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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 <anna@addaleax.net> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
- Loading branch information
1 parent
bd952ea
commit 528c659
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()); |