Skip to content

Commit 9e8713b

Browse files
committedFeb 13, 2023
fix: add expected default value 200, closes #349
1 parent 2ebf1ba commit 9e8713b

File tree

4 files changed

+18
-0
lines changed

4 files changed

+18
-0
lines changed
 

‎README.md

+2
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,8 @@ $ start-test --expect 403 start :9000 test:e2e
177177

178178
See `demo-expect-403` NPM script.
179179

180+
Default expected value is 200.
181+
180182
## `npx` and `yarn`
181183

182184
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:

‎src/bin/start.js

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ if (!Array.isArray(services)) {
1818
throw new Error(`Could not parse arguments %o, got %o`, args, parsed)
1919
}
2020

21+
if (!namedArguments.expect) {
22+
namedArguments.expect = 200
23+
}
24+
2125
utils.printArguments({ services, test, namedArguments })
2226

2327
startAndTest({ services, test, namedArguments }).catch(e => {

‎src/index.js

+6
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,12 @@ function startAndTest ({ services, test, namedArguments }) {
130130
throw new Error('Got zero services to start ...')
131131
}
132132

133+
la(
134+
is.number(namedArguments.expect),
135+
'expected status should be a number',
136+
namedArguments.expect
137+
)
138+
133139
if (services.length === 1) {
134140
const runTests = runTheTests(test)
135141
debug('single service "%s" to run and test', services[0].start)

‎src/utils.js

+6
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,12 @@ const normalizeUrl = input => {
218218
}
219219

220220
function printArguments ({ services, test, namedArguments }) {
221+
la(
222+
is.number(namedArguments.expect),
223+
'expected status code should be a number',
224+
namedArguments.expect
225+
)
226+
221227
services.forEach((service, k) => {
222228
console.log('%d: starting server using command "%s"', k + 1, service.start)
223229
console.log(

0 commit comments

Comments
 (0)
Please sign in to comment.