Skip to content

Commit fb9f784

Browse files
committed
Merge pull request parse-community#843 from drew-gross/improve-tests
Fix leak warnings in tests, use mongodb-runner from node_modules
2 parents c6ae64b + e074a92 commit fb9f784

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"build": "./node_modules/.bin/babel src/ -d lib/",
6060
"pretest": "cross-env MONGODB_VERSION=${MONGODB_VERSION:=3.0.8} ./node_modules/.bin/mongodb-runner start",
6161
"test": "cross-env NODE_ENV=test TESTING=1 ./node_modules/.bin/babel-node $COVERAGE_OPTION ./node_modules/jasmine/bin/jasmine.js",
62-
"posttest": "mongodb-runner stop",
62+
"posttest": "./node_modules/.bin/mongodb-runner stop",
6363
"coverage": "cross-env COVERAGE_OPTION='./node_modules/babel-istanbul/lib/cli.js cover -x **/spec/**' npm test",
6464
"start": "node ./bin/parse-server",
6565
"prepublish": "npm run build"

src/index.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -232,15 +232,18 @@ function ParseServer({
232232

233233
api.use(middlewares.handleParseErrors);
234234

235-
process.on('uncaughtException', (err) => {
236-
if( err.code === "EADDRINUSE" ) { // user-friendly message for this common error
237-
console.log(`Unable to listen on port ${err.port}. The port is already in use.`);
238-
process.exit(0);
239-
}
240-
else {
241-
throw err;
242-
}
243-
});
235+
//This causes tests to spew some useless warnings, so disable in test
236+
if (!process.env.TESTING) {
237+
process.on('uncaughtException', (err) => {
238+
if( err.code === "EADDRINUSE" ) { // user-friendly message for this common error
239+
console.log(`Unable to listen on port ${err.port}. The port is already in use.`);
240+
process.exit(0);
241+
}
242+
else {
243+
throw err;
244+
}
245+
});
246+
}
244247
hooksController.load();
245248

246249
return api;

0 commit comments

Comments
 (0)