Skip to content

Commit ce71897

Browse files
committed
fix: fixed tests
1 parent b5c426f commit ce71897

File tree

4 files changed

+22
-19
lines changed

4 files changed

+22
-19
lines changed

.xo-config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
module.exports = {
22
prettier: true,
33
space: true,
4-
extends: ['xo-lass']
4+
extends: ['xo-lass'],
5+
rules: {
6+
'import/order': 'off'
7+
}
58
};

index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
const process = require('node:process');
2-
32
const mergeOptions = require('merge-options');
43
const mongoose = require('mongoose');
54
const { boolean } = require('boolean');
@@ -23,14 +22,15 @@ class Mongoose {
2322
bindEvents: true,
2423
mongo: {
2524
options: {
26-
serverSelectionTimeoutMS: 30000, // default is 30s
27-
heartbeatFrequencyMS: 10000 // default is 10s
25+
serverSelectionTimeoutMS:
26+
process.env.NODE_ENV === 'test' ? 9000 : 30000, // default is 30s
27+
heartbeatFrequencyMS: process.env.NODE_ENV === 'test' ? 3000 : 10000 // default is 10s
2828
}
2929
},
3030
debug: boolean(process.env.MONGOOSE_DEBUG),
3131
strict: true,
3232
strictQuery: false,
33-
maxTimeMS: 30000 // default 30s timeout for a query to complete
33+
maxTimeMS: process.env.NODE_ENV === 'test' ? 10000 : 30000 // default 30s timeout for a query to complete
3434
},
3535
config
3636
);
@@ -69,7 +69,7 @@ class Mongoose {
6969
];
7070

7171
for (const prop of options) {
72-
if (typeof this.config[prop] !== 'undefined')
72+
if (this.config[prop] !== undefined)
7373
mongoose.set(prop, this.config[prop]);
7474
}
7575

package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,22 @@
2121
"merge-options": "^3.0.4"
2222
},
2323
"devDependencies": {
24-
"@commitlint/cli": "^17.4.2",
25-
"@commitlint/config-conventional": "^17.4.2",
26-
"ava": "^5.1.1",
24+
"@commitlint/cli": "^19.3.0",
25+
"@commitlint/config-conventional": "^19.2.2",
26+
"ava": "5",
2727
"cross-env": "^7.0.3",
28-
"delay": "^5.0.0",
28+
"delay": "5.0.0",
2929
"eslint-config-xo-lass": "^2.0.1",
3030
"fixpack": "^4.0.0",
31-
"husky": "^8.0.3",
32-
"lint-staged": "^13.1.0",
33-
"mongodb-memory-server": "^8.11.4",
31+
"husky": "^9.0.11",
32+
"lint-staged": "^15.2.7",
33+
"mongodb-memory-server": "^9.4.0",
3434
"mongoose": "^6.9.0",
35-
"nyc": "^15.1.0",
36-
"remark-cli": "^11.0.0",
35+
"nyc": "^17.0.0",
36+
"remark-cli": "11.0.0",
3737
"remark-preset-github": "^4.0.4",
3838
"signale": "^1.4.0",
39-
"xo": "^0.53.1"
39+
"xo": "^0.58.0"
4040
},
4141
"engines": {
4242
"node": ">=14"

test/test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ test('creates, stops, and retries connection with mongodb-memory-server', async
7070
if (process.platform === 'darwin') {
7171
test('reconnects with mongodb', async (t) => {
7272
t.timeout(Number.MAX_VALUE);
73-
await exec('brew services start mongodb-community@4.4');
73+
await exec('brew services start mongodb-community');
7474
await delay(3000);
7575
const m = new Mongoose({
7676
logger,
@@ -83,12 +83,12 @@ if (process.platform === 'darwin') {
8383
await delay(1000);
8484
t.is(conn.readyState, 1);
8585
const MyModel = conn.model('Test', new Schema({ name: String }));
86-
await exec('brew services stop mongodb-community@4.4');
86+
await exec('brew services stop mongodb-community');
8787
await delay(1000);
8888
t.is(conn.readyState, 0);
8989
const err = await t.throwsAsync(() => MyModel.findOne());
9090
t.is(err.name, 'MongooseServerSelectionError');
91-
await exec('brew services start mongodb-community@4.4');
91+
await exec('brew services start mongodb-community');
9292
await delay(5000);
9393
await t.notThrowsAsync(() => MyModel.findOne());
9494
t.is(conn.readyState, 1);

0 commit comments

Comments
 (0)