diff --git a/.travis.yml b/.travis.yml index 3939a237..a183732a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,6 +16,7 @@ script: - npm run demo6 - npm run demo7 - START_SERVER_AND_TEST_INSECURE=1 npm run demo9 + - npm run demo11 - npm run demo-cross-env after_success: - npm run travis-deploy-once "npm run semantic-release" diff --git a/bin/start.js b/bin/start.js index 58a9ffca..7e7060bd 100755 --- a/bin/start.js +++ b/bin/start.js @@ -8,6 +8,7 @@ const utils = require('../src/utils') let start = 'start' let test = 'test' let url +let interval = 2000 if (args.length === 1 && utils.isUrlOrPort(args[0])) { // passed just single url or port number, for example @@ -26,18 +27,26 @@ if (args.length === 1 && utils.isUrlOrPort(args[0])) { start = args[0] url = utils.normalizeUrl(args[1]) } -} else { - la(args.length === 3, 'expect: ') +} else if (args.length <= 4) { start = args[0] url = utils.normalizeUrl(args[1]) test = args[2] + + if (args.length === 4) { + interval = args[3] + } +} else { + la( + false, + 'expect: ' + ) } console.log(`starting server using command "npm run ${start}"`) console.log(`and when url "${url}" is responding`) console.log(`running tests using command "${test}"`) -startAndTest({ start, url, test }).catch(e => { +startAndTest({ start, url, test, interval }).catch(e => { console.error(e) process.exit(1) }) diff --git a/package.json b/package.json index 90d01582..66c7a006 100644 --- a/package.json +++ b/package.json @@ -90,6 +90,7 @@ "demo8": "node bin/start.js start-multiple \":9000|:9001\" test3", "demo9": "node bin/start.js start-https \"https://127.0.0.1:9000\" test4", "demo10": "node bin/start.js start-fail http://127.0.0.1:9000 test", + "demo11": "node bin/start.js start http://127.0.0.1:9000 test2 1000", "demo-cross-env": "node bin/start.js start-cross-env 9000", "travis-deploy-once": "travis-deploy-once" }, diff --git a/src/index.js b/src/index.js index 70c66001..cac42e18 100644 --- a/src/index.js +++ b/src/index.js @@ -13,7 +13,7 @@ const isDebug = () => const isInsecure = () => process.env.START_SERVER_AND_TEST_INSECURE -function startAndTest ({ start, url, test }) { +function startAndTest ({ start, url, test, interval }) { la(is.unemptyString(start), 'missing start script name', start) la(is.unemptyString(test), 'missing test script name', test) la( @@ -66,7 +66,7 @@ function startAndTest ({ start, url, test }) { waitOn( { resources: Array.isArray(url) ? url : [url], - interval: 2000, + interval: interval, window: 1000, verbose: isDebug(), strictSSL: !isInsecure(),