-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expand file tree
/
Copy pathdev-server-command.test.mjs
More file actions
52 lines (46 loc) · 1.26 KB
/
dev-server-command.test.mjs
File metadata and controls
52 lines (46 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import assert from 'node:assert/strict'
import test from 'node:test'
import { createChatlabStartCommand, terminateChatlabStartProcess } from './dev-server-command.mjs'
test('web dev backend runs through the current Node executable with the tsx loader', () => {
const command = createChatlabStartCommand({
rootDir: '/repo',
serverDir: '/repo/apps/cli',
coreDir: '/repo/packages/core/src',
runtimeDir: '/repo/packages/node-runtime/src',
backendPort: 3110,
nodeExecutable: '/custom/node',
})
assert.equal(command.command, '/custom/node')
assert.deepEqual(command.args, [
'--watch',
'--import',
'tsx',
'src/cli.ts',
'start',
'--headless',
'--no-open',
'--port',
'3110',
])
assert.equal(command.options.detached, true)
})
test('web dev backend cleanup terminates the whole POSIX process group', () => {
const killed = []
const proc = {
pid: 12345,
exitCode: null,
signalCode: null,
kill(signal) {
killed.push(['child', signal])
return true
},
}
terminateChatlabStartProcess(proc, {
platform: 'darwin',
killProcess: (pid, signal) => {
killed.push(['process', pid, signal])
return true
},
})
assert.deepEqual(killed, [['process', -12345, 'SIGTERM']])
})