setup.js 734 B

123456789101112131415161718192021222324252627
  1. /** **********************************************************
  2. * Caution
  3. *
  4. * Module aliases by compilerOptions.paths in tsconfig.json
  5. * are NOT available in setup scripts
  6. *********************************************************** */
  7. const gc = require('expose-gc/function');
  8. const mongoose = require('mongoose');
  9. const { initMongooseGlobalSettings, getMongoUri, mongoOptions } = require('~/server/util/mongoose-utils');
  10. mongoose.Promise = global.Promise;
  11. jest.setTimeout(30000); // default 5000
  12. beforeAll(async() => {
  13. initMongooseGlobalSettings();
  14. await mongoose.connect(getMongoUri(), mongoOptions);
  15. });
  16. afterAll(async() => {
  17. await mongoose.disconnect();
  18. gc();
  19. });
  20. module.exports = {};