MCPcopy
hub / github.com/vercel/next.js / testExitSignal

Function testExitSignal

test/integration/cli/test/index.test.ts:55–84  ·  view source on GitHub ↗
(
  killSignal = '',
  args = [],
  readyRegex = /Creating an optimized production/,
  expectedCode = 0
)

Source from the content-addressed store, hash-verified

53}
54
55const testExitSignal = async (
56 killSignal = '',
57 args = [],
58 readyRegex = /Creating an optimized production/,
59 expectedCode = 0
60) => {
61 let instance
62 const killSigint = (inst) => {
63 instance = inst
64 }
65 let output = ''
66
67 let cmdPromise = runNextCommand(args, {
68 ignoreFail: true,
69 instance: killSigint,
70 onStdout: (msg) => {
71 output += stripAnsi(msg)
72 },
73 }).catch((err) => expect.fail(err.message))
74
75 await check(() => output, readyRegex)
76 instance.kill(killSignal)
77
78 const { code, signal } = await cmdPromise
79 // Node can only partially emulate signals on Windows. Our signal handlers won't affect the exit code.
80 // See: https://nodejs.org/api/process.html#process_signal_events
81 const expectedExitSignal = process.platform === `win32` ? killSignal : null
82 expect(signal).toBe(expectedExitSignal)
83 expect(code).toBe(expectedCode)
84}
85
86describe('CLI Usage', () => {
87 ;(process.env.TURBOPACK_DEV ? describe.skip : describe)(

Callers 1

index.test.tsFile · 0.85

Calls 6

runNextCommandFunction · 0.90
checkFunction · 0.90
failMethod · 0.80
killMethod · 0.65
expectFunction · 0.50
catchMethod · 0.45

Tested by

no test coverage detected