Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(api): adds check for http status 304 #311

Merged
merged 2 commits into from
Jul 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
npm run demo7
# hmm why are some demos skipped?
npm run demo11
npm run demo12
START_SERVER_AND_TEST_INSECURE=1 npm run demo9
npm run demo-cross-env
npm run demo-commands
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
"start-multiple": "node test/multiple-servers.js",
"start-https": "node test/https-server.js",
"start-fail": "node test/server-fail.js",
"start-304": "node test/server-304.js",
"start-cross-env": "cross-env FOO=bar node test/server.js",
"test2": "curl http://127.0.0.1:9000",
"test3": "curl http://127.0.0.1:9000 && curl http://127.0.0.1:9001",
Expand All @@ -90,6 +91,7 @@
"demo9": "node src/bin/start.js start-https \"https://127.0.0.1:9000\" test4",
"demo10": "node src/bin/start.js start-fail http://127.0.0.1:9000 test",
"demo11": "node src/bin/start.js http-get://127.0.0.1:9000",
"demo12": "node src/bin/start.js start-304 9000 test2",
"demo-cross-env": "node src/bin/start.js start-cross-env 9000",
"demo-commands": "node src/bin/start.js 'node test/server.js --port 8800' 8800 'node test/client --port 8800'",
"demo-multiple": "node src/bin/start.js 'node test/server --port 6000' 6000 'node test/server --port 6010' 6010 'curl http://127.0.0.1:6000 && curl http://127.0.0.1:6010'",
Expand Down
3 changes: 2 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ function waitAndRun ({ start, url, runFn }) {
log: isDebug(),
headers: {
Accept: 'text/html, application/json, text/plain, */*'
}
},
validateStatus: (status) => (status >= 200 && status < 300) || status === 304,
}
debug('wait-on options %o', options)

Expand Down
20 changes: 20 additions & 0 deletions test/server-304.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const argv = require('minimist')(process.argv.slice(2), {
alias: {
port: 'p'
}
})
const http = require('http')
const server = http.createServer((req, res) => {
console.log(req.method)
if (req.method === 'GET') {
res.writeHead(304).end('All good\n\n')
} else {
res.end()
}
})
const port = argv.port || 9000
setTimeout(() => {
server.listen(port)
console.log('listening at port %d', port)
}, 5000)
console.log('sleeping for 5 seconds before starting')