-
Notifications
You must be signed in to change notification settings - Fork 10.3k
/
ipc-send.js
50 lines (41 loc) · 1.09 KB
/
ipc-send.js
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
const { spawn } = require(`child_process`)
const path = require(`path`)
jest.setTimeout(20000) // 20s
const gatsbyBin = path.join(`node_modules`, `gatsby`, `cli.js`)
describe(`IPC Send`, () => {
let gatsbyProcess
beforeAll(() => {
gatsbyProcess = spawn(process.execPath, [gatsbyBin, `develop`], {
stdio: [`ignore`, `ignore`, `ignore`, `ipc`],
env: {
...process.env,
NODE_ENV: `development`,
},
})
})
afterAll(() => {
gatsbyProcess.kill()
})
// TODO remove to a more global integration test but for now we want to make sure it gets an external send command
it(`should kill the develop process when exit command is given`, done => {
expect.assertions(1)
gatsbyProcess.on("exit", () => {
expect(true).toBe(true)
done()
})
let hasSentExitCode
gatsbyProcess.on("message", msg => {
if (hasSentExitCode) {
return
}
hasSentExitCode = true
gatsbyProcess.send({
type: "COMMAND",
action: {
type: "EXIT",
payload: "SIGINT",
},
})
})
})
})