setup.js 676 B

12345678910111213141516171819202122232425262728293031323334353637
  1. const chai = require('chai')
  2. const SandboxedModule = require('sandboxed-module')
  3. const sinon = require('sinon')
  4. // Chai configuration
  5. chai.should()
  6. // Global stubs
  7. const sandbox = sinon.createSandbox()
  8. const stubs = {
  9. logger: {
  10. debug: sandbox.stub(),
  11. log: sandbox.stub(),
  12. warn: sandbox.stub(),
  13. err: sandbox.stub(),
  14. error: sandbox.stub()
  15. }
  16. }
  17. // SandboxedModule configuration
  18. SandboxedModule.configure({
  19. requires: {
  20. 'logger-sharelatex': stubs.logger
  21. },
  22. globals: { Buffer, JSON, Math, console, process }
  23. })
  24. // Mocha hooks
  25. exports.mochaHooks = {
  26. beforeEach() {
  27. this.logger = stubs.logger
  28. },
  29. afterEach() {
  30. sandbox.reset()
  31. }
  32. }