Files
2026-07-13 12:47:58 +08:00

22 lines
606 B
TypeScript

import { expect } from 'vitest'
import { ProcessExitError } from '../../../src/index.js'
import { sandboxTest } from '../../setup.js'
sandboxTest('kill process', async ({ sandbox }) => {
const cmd = await sandbox.commands.run('sleep 10', { background: true })
const pid = cmd.pid
await sandbox.commands.kill(pid)
await expect(sandbox.commands.run(`kill -0 ${pid}`)).rejects.toThrowError(
ProcessExitError
)
})
sandboxTest('kill non-existing process', async ({ sandbox }) => {
const nonExistingPid = 999999
await expect(sandbox.commands.kill(nonExistingPid)).resolves.toBe(false)
})