setup.js 760 B

123456789101112131415161718192021222324252627282930
  1. const chai = require('chai')
  2. const SandboxedModule = require('sandboxed-module')
  3. // Chai configuration
  4. chai.should()
  5. // ensure every ObjectId has the id string as a property for correct comparisons
  6. require('mongodb-legacy').ObjectId.cacheHexString = true
  7. // SandboxedModule configuration
  8. SandboxedModule.configure({
  9. requires: {
  10. '@overleaf/logger': {
  11. debug() {},
  12. log() {},
  13. info() {},
  14. warn() {},
  15. err() {},
  16. error() {},
  17. fatal() {},
  18. },
  19. 'mongodb-legacy': require('mongodb-legacy'), // for ObjectId comparisons
  20. },
  21. globals: { Buffer, JSON, console, process },
  22. sourceTransformers: {
  23. removeNodePrefix: function (source) {
  24. return source.replace(/require\(['"]node:/g, "require('")
  25. },
  26. },
  27. })