Browse Source

specify mongodb version with env var

Yuki Takei 2 years ago
parent
commit
cdc52dc13c
2 changed files with 20 additions and 1 deletions
  1. 9 0
      apps/app/.env.test
  2. 11 1
      apps/app/test-with-vite/setup/mongoms.ts

+ 9 - 0
apps/app/.env.test

@@ -0,0 +1,9 @@
+##
+## Handled by vite
+## https://vitejs.dev/guide/env-and-mode.html
+##
+## > To prevent accidentally leaking env variables to the client, only variables prefixed with
+## > VITE_ are exposed to your Vite-processed code. e.g. for the following env variables:
+##
+VITE_MONGOMS_VERSION="6.0.6"
+# VITE_MONGOMS_DEBUG=1

+ 11 - 1
apps/app/test-with-vite/setup/mongoms.ts

@@ -5,8 +5,18 @@ import { mongoOptions } from '../../src/server/util/mongoose-utils';
 
 
 beforeAll(async() => {
+  // set debug flag
+  process.env.MONGOMS_DEBUG = process.env.VITE_MONGOMS_DEBUG;
+
+  // set version
   const mongoServer = await MongoMemoryServer.create({
-    instance: { dbName: 'growi_test' },
+    instance: {
+      dbName: 'growi_test',
+    },
+    binary: {
+      version: process.env.VITE_MONGOMS_VERSION,
+      downloadDir: 'node_modules/.cache/mongodb-binaries',
+    },
   });
   await mongoose.connect(mongoServer.getUri(), mongoOptions);
 });