Skip to content

Commit

Permalink
ref(test): Switch to mongodb-memory-server-global (#4872)
Browse files Browse the repository at this point in the history
Switching to `mongodb-memory-server-global` which downloads MongoDB binaries on `postinstall` instead of first test run. This will fix test flakiness caused by timeouts.
  • Loading branch information
onurtemizkan authored and lobsterkatie committed Apr 26, 2022
1 parent 7078e47 commit 6e21baf
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ env:
${{ github.workspace }}/node_modules
${{ github.workspace }}/packages/**/node_modules
~/.cache/ms-playwright/
~/.cache/mongodb-binaries/
# DEPENDENCY_CACHE_KEY: can't be set here because we don't have access to yarn.lock

Expand Down
8 changes: 7 additions & 1 deletion packages/node-integration-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,16 @@
"cors": "^2.8.5",
"express": "^4.17.3",
"mongodb": "^3.7.3",
"mongodb-memory-server": "^7.6.3",
"mongodb-memory-server-global": "^7.6.3",
"mysql": "^2.18.1",
"nock": "^13.1.0",
"pg": "^8.7.3",
"portfinder": "^1.0.28"
},
"config": {
"mongodbMemoryServer": {
"preferGlobalPath": true,
"runtimeDownload": false
}
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
import { MongoMemoryServer } from 'mongodb-memory-server';
import { MongoMemoryServer } from 'mongodb-memory-server-global';

import { assertSentryTransaction, conditionalTest, getEnvelopeRequest, runServer } from '../../../../utils';

// This test can take longer.
jest.setTimeout(15000);

conditionalTest({ min: 12 })('MongoDB Test', () => {
let mongoServer: MongoMemoryServer;

beforeAll(async () => {
mongoServer = await MongoMemoryServer.create();
process.env.MONGO_URL = mongoServer.getUri();
}, 40000);
}, 10000);

afterAll(async () => {
await mongoServer.stop();
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -16286,10 +16286,10 @@ [email protected]:
uuid "^8.3.1"
yauzl "^2.10.0"

mongodb-memory-server@^7.6.3:
mongodb-memory-server-global@^7.6.3:
version "7.6.3"
resolved "https://registry.yarnpkg.com/mongodb-memory-server/-/mongodb-memory-server-7.6.3.tgz#8b2827363ca16aaf250cba07f7a2b49e502735d4"
integrity sha512-yHDE9FGxOpSRUzitF9Qx3JjEgayCSJI3JOW2wgeBH/5PAsUdisy2nRxRiNwwLDooQ7tohllWCRTXlWqyarUEMQ==
resolved "https://registry.yarnpkg.com/mongodb-memory-server-global/-/mongodb-memory-server-global-7.6.3.tgz#ad662a640db254eea7927668834c26b665c13547"
integrity sha512-WLlMqkEasuanHjoxyMxlyvQ/HtJgq0eGyrfCXX6lTnY/26Zfs96W2daeWLOQ48VLInSOh2umBvE74Ykqj7gVyA==
dependencies:
mongodb-memory-server-core "7.6.3"
tslib "^2.3.0"
Expand Down

0 comments on commit 6e21baf

Please sign in to comment.