Skip to content

Commit

Permalink
fix: setup - pass error to done when SUT fails to start
Browse files Browse the repository at this point in the history
  • Loading branch information
osher committed May 25, 2020
1 parent 2807ed9 commit 06e7a2f
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 90 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
node_modules
coverage

package-lock.json
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
language: node_js
node_js:
- "14"
- "12"
- "10"
- "8"
- "7"
- "6"

after_success:
npm run coveralls
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
e2e-helper
==========
## 0.9.4
- setup - fix - pass error to `done` when SUT fails to start
- include node v12.x and v14.x in tests

## 0.9.3
- add in Readme.md the undocumented feature: `options.env`
- include node v10.x in tests
Expand Down
7 changes: 6 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,10 @@ function setup(ctx, test, done) {

/* istanbul ignore if */
writeLog('ERR: ' + data)
if (~data.indexOf('Error: listen EADDRINUSE')) done(new Error('Server could not start: Address In Use'))
if (~data.indexOf('Error: listen EADDRINUSE')) {
done(new Error('Server could not start: Address In Use'))
done = null
}
})

child.stdout.on('data', (data) => {
Expand All @@ -285,6 +288,7 @@ function setup(ctx, test, done) {
if (~data.indexOf(ctx.readyNotice)) {
ctx.console.log('service started: %s', ctx.args.join(' '))
done()
done = null
}
})

Expand All @@ -294,6 +298,7 @@ function setup(ctx, test, done) {
ctx.log.writable = false
ctx.log.end(() => {
child.emit('--over--')
e && done && done(new Error('failed to start. exit code:' + e))
})
})
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"coveralls": "^3.0.0",
"eslint": "^4.15.0",
"istanbul": "*",
"mocha": "~2.3.4",
"mocha": "^7.2.0",
"mocha-ui-exports": "^1.1.0",
"should": "^9.0.0"
},
Expand Down
Loading

0 comments on commit 06e7a2f

Please sign in to comment.