global-setup.js 959 B

1234567891011121314151617181920212223242526272829303132333435
  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 { getMongoUri, mongoOptions } from '~/server/util/mongoose-utils';
  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. await mongoose.connect(getMongoUri(), mongoOptions);
  18. // drop database
  19. await mongoose.connection.dropDatabase();
  20. // init DB
  21. // const crowi = await getInstance();
  22. // const appService = crowi.appService;
  23. // await appService.initDB();
  24. await mongoose.disconnect();
  25. };