Skip to content

Commit c5aad84

Browse files
committed
test(MongooseConnection): Remove handling uncaughtException we should get real error in tests.
1 parent 3883e7a commit c5aad84

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/__mocks__/mongooseCommon.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable no-param-reassign, no-console */
12
import mongoose, { Schema } from 'mongoose';
23

34
function getRandomInt(min, max) {
@@ -15,19 +16,20 @@ mongoose.connection.on('error', (err) => {
1516
});
1617

1718
mongoose.connection.on('connected', () => {
18-
console.log('Mongoose default connection open to ' + uri);
19+
console.log(`Mongoose default connection open to ${uri}`);
1920
});
2021

2122
function dropDBs(done) {
22-
mongoose.connection.db.dropDatabase(() => {
23-
if (done) {
24-
done();
25-
}
26-
});
23+
try {
24+
mongoose.connection.db.dropDatabase(() => {
25+
if (done) done();
26+
});
27+
} catch (e) { // Pitty, but not deathly
28+
if (done) done();
29+
}
2730
}
2831

2932
process.on('exit', () => { dropDBs(); });
30-
process.on('uncaughtException', () => { dropDBs(); });
3133
process.on('SIGINT', () => { dropDBs(); });
3234

3335
export {

0 commit comments

Comments
 (0)