setup.js 682 B

12345678910111213141516171819202122232425262728293031323334
  1. const sinon = require('sinon')
  2. const SandboxedModule = require('sandboxed-module')
  3. // ensure every ObjectId has the id string as a property for correct comparisons
  4. require('mongodb').ObjectId.cacheHexString = true
  5. const sandbox = sinon.createSandbox()
  6. const stubs = {
  7. logger: {
  8. debug: sandbox.stub(),
  9. log: sandbox.stub(),
  10. info: sandbox.stub(),
  11. warn: sandbox.stub(),
  12. err: sandbox.stub(),
  13. error: sandbox.stub(),
  14. fatal: sandbox.stub(),
  15. },
  16. }
  17. SandboxedModule.configure({
  18. requires: {
  19. '@overleaf/logger': stubs.logger,
  20. },
  21. })
  22. exports.mochaHooks = {
  23. beforeEach() {
  24. this.logger = stubs.logger
  25. },
  26. afterEach() {
  27. sandbox.reset()
  28. },
  29. }