Skip to content

Commit bf40050

Browse files
committed
test: add "globalSetup" to ensure versions are downloaded before tests
1 parent 1d68784 commit bf40050

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

packages/mongodb-memory-server-core/jest.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ module.exports = {
1818
'<rootDir>/src/**/*.ts', // include all files, even files that have no tests yet (or are never called)
1919
'!<rootDir>/src/util/postinstallHelper.ts', // exclude this file, because it is only made for postInstall, not tests
2020
],
21+
globalSetup: '<rootDir>/src/__tests__/testUtils/globalSetup.ts',
2122
};
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import MongoBinary from '../../util/MongoBinary';
2+
import resolveConfig, { ResolveConfigVariables } from '../../util/resolveConfig';
3+
import { assertion, isNullOrUndefined } from '../../util/utils';
4+
5+
export = async function globalSetup(): Promise<void> {
6+
const defaultVersion = resolveConfig(ResolveConfigVariables.VERSION);
7+
assertion(!isNullOrUndefined(defaultVersion), new Error('Default version is not defined'));
8+
const versions = [defaultVersion, '4.0.3'];
9+
// Ensure all required versions are downloaded for tests
10+
for (const version of versions) {
11+
await MongoBinary.getPath({ version });
12+
}
13+
};

0 commit comments

Comments
 (0)