test: add spec for app.getAppMetrics()
for utility process (#40306)
This commit is contained in:
parent
a867503af6
commit
54ff706b71
1 changed files with 31 additions and 0 deletions
|
@ -6,6 +6,7 @@ import { ifit } from './lib/spec-helpers';
|
|||
import { closeWindow } from './lib/window-helpers';
|
||||
import { once } from 'node:events';
|
||||
import { pathToFileURL } from 'node:url';
|
||||
import { setImmediate } from 'node:timers/promises';
|
||||
|
||||
const fixturesPath = path.resolve(__dirname, 'fixtures', 'api', 'utility-process');
|
||||
const isWindowsOnArm = process.platform === 'win32' && process.arch === 'arm64';
|
||||
|
@ -113,6 +114,36 @@ describe('utilityProcess module', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('app.getAppMetrics()', () => {
|
||||
it('with default serviceName', async () => {
|
||||
const child = utilityProcess.fork(path.join(fixturesPath, 'endless.js'));
|
||||
await once(child, 'spawn');
|
||||
expect(child.pid).to.not.be.null();
|
||||
|
||||
await setImmediate();
|
||||
|
||||
const details = app.getAppMetrics().find(item => item.pid === child.pid)!;
|
||||
expect(details).to.be.an('object');
|
||||
expect(details.type).to.equal('Utility');
|
||||
expect(details.serviceName).to.to.equal('node.mojom.NodeService');
|
||||
expect(details.name).to.equal('Node Utility Process');
|
||||
});
|
||||
|
||||
it('with custom serviceName', async () => {
|
||||
const child = utilityProcess.fork(path.join(fixturesPath, 'endless.js'), [], { serviceName: 'Hello World!' });
|
||||
await once(child, 'spawn');
|
||||
expect(child.pid).to.not.be.null();
|
||||
|
||||
await setImmediate();
|
||||
|
||||
const details = app.getAppMetrics().find(item => item.pid === child.pid)!;
|
||||
expect(details).to.be.an('object');
|
||||
expect(details.type).to.equal('Utility');
|
||||
expect(details.serviceName).to.to.equal('node.mojom.NodeService');
|
||||
expect(details.name).to.equal('Hello World!');
|
||||
});
|
||||
});
|
||||
|
||||
describe('kill() API', () => {
|
||||
it('terminates the child process gracefully', async () => {
|
||||
const child = utilityProcess.fork(path.join(fixturesPath, 'endless.js'), [], {
|
||||
|
|
Loading…
Reference in a new issue