setup.js 707 B

12345678910111213141516171819202122232425262728293031323334
  1. import { afterEach, beforeEach, chai, vi } from 'vitest'
  2. import sinon from 'sinon'
  3. import chaiAsPromised from 'chai-as-promised'
  4. import sinonChai from 'sinon-chai'
  5. // Chai configuration
  6. chai.should()
  7. chai.use(chaiAsPromised)
  8. chai.use(sinonChai)
  9. // Global stubs
  10. const sandbox = sinon.createSandbox()
  11. const stubs = {
  12. logger: {
  13. debug: sandbox.stub(),
  14. log: sandbox.stub(),
  15. info: sandbox.stub(),
  16. warn: sandbox.stub(),
  17. err: sandbox.stub(),
  18. error: sandbox.stub(),
  19. },
  20. }
  21. // Mocha hooks
  22. beforeEach(ctx => {
  23. ctx.logger = stubs.logger
  24. vi.doMock('@overleaf/logger', () => ({ default: ctx.logger }))
  25. })
  26. afterEach(() => {
  27. sandbox.reset()
  28. vi.restoreAllMocks()
  29. vi.resetModules()
  30. })