This repository was archived by the owner on Nov 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 282
This repository was archived by the owner on Nov 8, 2024. It is now read-only.
Running express server in hooks.beforeAll never enters callback function (hangs) #685
Copy link
Copy link
Open
Labels
Description
I'm trying to start an express server before running dredd in hooks.beforeAll but execution is never entering express server's onListening callback. It just hangs indefinitely.
npm run dredd
dredd npm script is: dredd ./api.apib http://localhost:9311 --hookfiles=./*-hooks.js
What is in your dredd.yml
?
Not using a dredd.yml in this bare bones test.
What's your dredd --version
output?
$ ./node_modules/.bin/dredd --version
dredd v2.2.5 (Darwin 15.4.0; x64)
Does dredd --level=debug
uncover something?
No:
> dredd ./api.apib http://localhost:9311 --hookfiles=./*-hooks.js --level=debug
verbose: Loading configuration file: ./dredd.yml
debug: Dredd version: 2.2.5
debug: Node.js version: v6.3.1
debug: Node.js environment: http_parser=2.7.0, node=6.3.1, v8=5.0.71.57, uv=1.9.1, zlib=1.2.8, ares=1.10.1-DEV, icu=57.1, modules=48, openssl=1.0.2h
debug: System version: Darwin 15.4.0 x64
debug: npm version: 3.10.3
debug: Configuration: {"server":"http://localhost:9311","options":{"_":["./api.apib"],"hookfiles":"./*-hooks.js","f":"./*-hooks.js","level":"debug","l":"debug","dry-run":null,"y":null,"language":"nodejs","a":"nodejs","sandbox":false,"b":false,"server":null,"g":null,"server-wait":3,"init":false,"i":false,"custom":{},"j":[],"names":false,"n":false,"only":[],"x":[],"reporter":[],"r":[],"output":[],"o":[],"header":[],"h":[],"sorted":false,"s":false,"user":null,"u":null,"inline-errors":false,"e":false,"details":false,"d":false,"method":[],"m":[],"color":true,"c":true,"timestamp":false,"t":false,"silent":false,"q":false,"path":["./api.apib","./api.apib"],"p":["./api.apib","./api.apib"],"hooks-worker-timeout":5000,"hooks-worker-connect-timeout":1500,"hooks-worker-connect-retry":500,"hooks-worker-after-connect-wait":100,"hooks-worker-term-timeout":5000,"hooks-worker-term-retry":500,"hooks-worker-handler-host":"localhost","hooks-worker-handler-port":61321,"config":"./dredd.yml","$0":"/Users/justin/tmp/tmp-dredd2/dredd-and-express/node_modules/.bin/dredd"},"custom":{"cwd":"/Users/justin/tmp/tmp-dredd2/dredd-and-express","argv":["./api.apib","http://localhost:9311","--hookfiles=./*-hooks.js","--level=debug"]}}
verbose: Using 'base' reporter.
verbose: Configuring reporters: []
verbose: Using 'cli' reporter.
verbose: No backend server process specified, starting testing at once.
verbose: Running Dredd instance.
verbose: Expanding glob patterns.
verbose: Reading API description files.
verbose: Parsing API description files and compiling a list of HTTP transactions to test.
verbose: Compiling HTTP transactions from API description file: ./api.apib
verbose: Starting reporters and waiting until all of them are ready.
info: Beginning Dredd testing...
verbose: Starting transaction runner.
verbose: Sorting HTTP transactions
verbose: Configuring HTTP transactions
verbose: Reading hook files and registering hooks
info: Found Hookfiles: 0=./tmp-hooks.js
verbose: Executing HTTP transactions
verbose: Running 'beforeAll' hooks
debug: Running hooks...
Can you send us failing test in a Pull Request?
Yes. You can also replicate with this:
tmp-hooks.js
:
let hooks = require('hooks');
let express = require('express');
let server = express();
const PORT = 9311;
server.get('/', function(req, res) {
res.json({message: 'Hello World!'});
});
hooks.beforeAll(function(transactions, done) {
return server.listen(PORT, function() {
// Never executes the following - just hangs
console.log(`--- Server up and listening on port: ${PORT}`);
return done();
});
});
api.apib
:
FORMAT: 1A
# GET /
+ Response 200 (application/json; charset=utf-8)
{"message": "Hello World!"}