diff --git a/README.md b/README.md index 6842bd3..ddd2450 100644 --- a/README.md +++ b/README.md @@ -177,6 +177,8 @@ $ start-test --expect 403 start :9000 test:e2e See `demo-expect-403` NPM script. +Default expected value is 200. + ## `npx` and `yarn` If you have [npx](https://www.npmjs.com/package/npx) available, you can execute locally installed tools from the shell. For example, if the `package.json` has the following local tools: diff --git a/src/bin/start.js b/src/bin/start.js index a1b3b47..3aea114 100755 --- a/src/bin/start.js +++ b/src/bin/start.js @@ -18,6 +18,10 @@ if (!Array.isArray(services)) { throw new Error(`Could not parse arguments %o, got %o`, args, parsed) } +if (!namedArguments.expect) { + namedArguments.expect = 200 +} + utils.printArguments({ services, test, namedArguments }) startAndTest({ services, test, namedArguments }).catch(e => { diff --git a/src/index.js b/src/index.js index 86c5d38..cca10d0 100644 --- a/src/index.js +++ b/src/index.js @@ -130,6 +130,12 @@ function startAndTest ({ services, test, namedArguments }) { throw new Error('Got zero services to start ...') } + la( + is.number(namedArguments.expect), + 'expected status should be a number', + namedArguments.expect + ) + if (services.length === 1) { const runTests = runTheTests(test) debug('single service "%s" to run and test', services[0].start) diff --git a/src/utils.js b/src/utils.js index 1bd3885..6062237 100644 --- a/src/utils.js +++ b/src/utils.js @@ -218,6 +218,12 @@ const normalizeUrl = input => { } function printArguments ({ services, test, namedArguments }) { + la( + is.number(namedArguments.expect), + 'expected status code should be a number', + namedArguments.expect + ) + services.forEach((service, k) => { console.log('%d: starting server using command "%s"', k + 1, service.start) console.log(