Skip to content

Commit

Permalink
Merge 17a8d42 into 7b2942c
Browse files Browse the repository at this point in the history
  • Loading branch information
johnjbarton authored Apr 13, 2020
2 parents 7b2942c + 17a8d42 commit de3ac29
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
13 changes: 7 additions & 6 deletions test/e2e/step_definitions/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ cucumber.defineSupportCode((a) => {
a.After(function (scenario, callback) {
const running = this.child != null && typeof this.child.kill === 'function'

if (running) {
this.child.kill()
this.child = null
}

// stop the proxy if it was started
this.proxy.stop(callback)
this.proxy.stop(() => {
if (running) {
this.child.kill()
this.child = null
}
callback()
})
})
})
8 changes: 8 additions & 0 deletions test/e2e/support/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ function Proxy () {
target: 'http://localhost:9876'
})

self.proxy.on('error', function proxyError (err, req, res) {
console.log('support/proxy onerror', err)
})

self.server = http.createServer(function (req, res) {
const url = req.url
const match = url.match(self.proxyPathRegExp)
Expand All @@ -22,6 +26,10 @@ function Proxy () {
}
})

self.server.on('clientError', (err, socket) => {
console.log('support/proxy clientError', err)
})

self.start = function (port, proxyPath, callback) {
self.proxyPathRegExp = new RegExp('^' + proxyPath + '(.*)')
self.server.listen(port, function (error) {
Expand Down

0 comments on commit de3ac29

Please sign in to comment.