Skip to content

Commit f63940b

Browse files
authored
chore: Replace usage of mongodb-runner mocha hooks with {pre,post}test scripts (#2309)
When used with the mocha hooks, mongodb-runner seems to fail tests with timeout quite often as it doesn't manage to start the server before mocha timeout throws. Hopefully moving this server start stop process to npm scripts will make CI a bit less flaky
1 parent 712fc54 commit f63940b

File tree

4 files changed

+4
-13
lines changed

4 files changed

+4
-13
lines changed

packages/connection-model/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515
],
1616
"scripts": {
1717
"test-check-ci": "npm run check && npm test",
18-
"pretest": "mongodb-runner install && node ../../scripts/rebuild.js keytar",
18+
"pretest": "mongodb-runner install && mongodb-runner start --port=27018 && node ../../scripts/rebuild.js keytar",
1919
"test": "mocha",
20+
"posttest": "mongodb-runner stop --port=27018",
2021
"check": "npm run lint && npm run depcheck",
2122
"lint": "eslint \"./{src,lib,test,bin}/**/*.{js,jsx,ts,tsx}\" \"./*.js\" --no-error-on-unmatched-pattern",
2223
"depcheck": "depcheck",

packages/connection-model/test/connect.test.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,6 @@ describe('connection model connector', () => {
1919
return;
2020
}
2121

22-
before(
23-
require('mongodb-runner/mocha/before')({ port: 27018 })
24-
);
25-
26-
after(
27-
require('mongodb-runner/mocha/after')({ port: 27018 })
28-
);
29-
3022
it('should return connection config when connected successfully', (done) => {
3123
Connection.from('mongodb://localhost:27018', (parseErr, model) => {
3224
if (parseErr) throw parseErr;

packages/index-model/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@
1515
],
1616
"scripts": {
1717
"check": "npm run lint && npm run depcheck",
18-
"pretest": "mongodb-runner install",
18+
"pretest": "mongodb-runner install && mongodb-runner start --port=27017",
1919
"test": "mocha",
20+
"posttest": "mongodb-runner stop --port=27017",
2021
"lint": "eslint \"./{src,lib,test,bin}/**/*.{js,jsx,ts,tsx}\" \"./*.js\" --no-error-on-unmatched-pattern",
2122
"depcheck": "depcheck",
2223
"test-ci": "npm run test",

packages/index-model/test/fetch.test.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ describe('fetch()', function() {
1616
return;
1717
}
1818

19-
before(require('mongodb-runner/mocha/before')());
20-
after(require('mongodb-runner/mocha/after')());
21-
2219
context('local', function() {
2320
this.slow(2000);
2421
this.timeout(10000);

0 commit comments

Comments
 (0)