Skip to content

Commit

Permalink
stop promise chains
Browse files Browse the repository at this point in the history
  • Loading branch information
flotwig committed Oct 15, 2019
1 parent d0b2a30 commit bc90d5f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/server/test/support/helpers/e2e.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,17 @@ normalizeStdout = (str, options = {}) ->
startServer = (obj) ->
{ onServer, port, https } = obj

console.log('STARTING ON', port)

app = express()

if https
srv = httpsProxy.httpsServer(app)
else
srv = http.Server(app)

srv.port = port

allowDestroy(srv)

app.use(morgan("dev"))
Expand All @@ -133,7 +137,13 @@ startServer = (obj) ->

resolve(srv)

## since the resolved object is a .thenable, it won't get wrapped in a
## Promise, which then leads to the rest of the Promise.chain getting no-op'd
stopPromise = () ->
{ then: stopPromise, catch: stopPromise }

stopServer = (srv) ->
console.log('STOPPING ON', srv.port)
srv.destroyAsync()

copy = ->
Expand Down Expand Up @@ -398,6 +408,8 @@ module.exports = e2e = {

return runAfterEach(ctx._runnable).then ->
ctx.skip()
## dirty-nasty trick to halt Promises chained off e2e.exec
stopPromise()

args = ["index.js"].concat(args)

Expand Down

0 comments on commit bc90d5f

Please sign in to comment.