diff --git a/package.json b/package.json index 60946ff6..11241671 100644 --- a/package.json +++ b/package.json @@ -63,7 +63,7 @@ "minimatch": "^3.0.4", "mkdirp": "^0.5.1", "pre-commit": "^1.2.2", - "proxyquire": "^2.0.1", + "proxyquire": "^2.1.3", "rimraf": "^3.0.0", "simple-get": "^3.0.3", "sinon": "^7.3.2", diff --git a/test/start.test.js b/test/start.test.js index 46cd95ef..60f95d5b 100644 --- a/test/start.test.js +++ b/test/start.test.js @@ -483,6 +483,53 @@ test('crash on unhandled rejection', t => { }) }) +if (!process.version.match(/v[0-6]\..*/g)) { + test('should start the server with inspect options and the defalut port is 9320', t => { + t.plan(4) + + const start = proxyquire('../start', { + inspector: { + open (p) { + t.strictEqual(p, 9320) + t.pass('inspect open called') + } + } + }) + const argv = ['--d', './examples/plugin.js'] + + start.start(argv, (err, fastify) => { + t.error(err) + + fastify.close(() => { + t.pass('server closed') + }) + }) + }) + + test('should start the server with inspect options and use the exactly port', t => { + t.plan(4) + + const port = getPort() + const start = proxyquire('../start', { + inspector: { + open (p) { + t.strictEqual(p, Number(port)) + t.pass('inspect open called') + } + } + }) + const argv = ['--d', '--debug-port', port, './examples/plugin.js'] + + start.start(argv, (err, fastify) => { + t.error(err) + + fastify.close(() => { + t.pass('server closed') + }) + }) + }) +} + test('boolean env are not overridden if no arguments are passed', t => { t.plan(1)