Files
overleaf-cep/services/web/test/unit/vitest_bootstrap.mjs
Andrew Rumble 4ca7136422 Update bootstrap process to use vitest chai
GitOrigin-RevId: 5576223019c0e2b4554707f0025e82ab3a7ca514
2025-06-10 08:05:23 +00:00

47 lines
897 B
JavaScript

import { chai, vi } from 'vitest'
import './common_bootstrap.js'
import sinon from 'sinon'
import logger from '@overleaf/logger'
import sinonChai from 'sinon-chai'
import chaiAsPromised from 'chai-as-promised'
/*
* Chai configuration
*/
// add chai.should()
chai.should()
// Load sinon-chai assertions so expect(stubFn).to.have.been.calledWith('abc')
// has a nicer failure messages
chai.use(sinonChai)
// Load promise support for chai
chai.use(chaiAsPromised)
// Do not truncate assertion errors
chai.config.truncateThreshold = 0
vi.mock('@overleaf/logger', async () => {
return {
default: {
debug: vi.fn(),
info: vi.fn(),
log: vi.fn(),
warn: vi.fn(),
err: vi.fn(),
error: vi.fn(),
fatal: vi.fn(),
},
}
})
beforeEach(ctx => {
ctx.logger = logger
})
afterEach(() => {
vi.restoreAllMocks()
vi.resetModules()
sinon.restore()
})