global-setup.js 1003 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /** **********************************************************
  2. * Caution
  3. *
  4. * Module aliases by compilerOptions.paths in tsconfig.json
  5. * are NOT available in setup scripts
  6. *********************************************************** */
  7. import 'tsconfig-paths/register';
  8. import mongoose from 'mongoose';
  9. import { initMongooseGlobalSettings, getMongoUri, mongoOptions } from '@growi/core';
  10. // check env
  11. if (process.env.NODE_ENV !== 'test') {
  12. throw new Error('\'process.env.NODE_ENV\' must be \'test\'');
  13. }
  14. // eslint-disable-next-line @typescript-eslint/no-var-requires
  15. // const { getInstance } = require('./setup-crowi');
  16. module.exports = async() => {
  17. initMongooseGlobalSettings();
  18. await mongoose.connect(getMongoUri(), mongoOptions);
  19. // drop database
  20. await mongoose.connection.dropDatabase();
  21. // init DB
  22. // const crowi = await getInstance();
  23. // const appService = crowi.appService;
  24. // await appService.initDB();
  25. await mongoose.disconnect();
  26. };