setup.js 701 B

1234567891011121314151617181920212223242526272829303132333435363738
  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. info: sandbox.stub(),
  13. warn: sandbox.stub(),
  14. err: sandbox.stub(),
  15. error: sandbox.stub(),
  16. },
  17. }
  18. // SandboxedModule configuration
  19. SandboxedModule.configure({
  20. requires: {
  21. 'logger-sharelatex': stubs.logger,
  22. },
  23. globals: { Buffer, JSON, console, process },
  24. })
  25. // Mocha hooks
  26. exports.mochaHooks = {
  27. beforeEach() {
  28. this.logger = stubs.logger
  29. },
  30. afterEach() {
  31. sandbox.reset()
  32. },
  33. }