Add vitest and configuration
GitOrigin-RevId: 1262f9f32a0db6a29d3feedd8158b8dd04e48b6a
This commit is contained in:
Vendored
+1
-24
@@ -1,29 +1,6 @@
|
||||
const Path = require('path')
|
||||
const chai = require('chai')
|
||||
const sinon = require('sinon')
|
||||
|
||||
/*
|
||||
* 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(require('sinon-chai'))
|
||||
|
||||
// Load promise support for chai
|
||||
chai.use(require('chai-as-promised'))
|
||||
|
||||
// Do not truncate assertion errors
|
||||
chai.config.truncateThreshold = 0
|
||||
|
||||
// add support for mongoose in sinon
|
||||
require('sinon-mongoose')
|
||||
|
||||
// ensure every ObjectId has the id string as a property for correct comparisons
|
||||
require('mongodb-legacy').ObjectId.cacheHexString = true
|
||||
require('./common_bootstrap')
|
||||
|
||||
/*
|
||||
* Global stubs
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
const chai = require('chai')
|
||||
|
||||
/*
|
||||
* 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(require('sinon-chai'))
|
||||
|
||||
// Load promise support for chai
|
||||
chai.use(require('chai-as-promised'))
|
||||
|
||||
// Do not truncate assertion errors
|
||||
chai.config.truncateThreshold = 0
|
||||
|
||||
// add support for mongoose in sinon
|
||||
require('sinon-mongoose')
|
||||
|
||||
// ensure every ObjectId has the id string as a property for correct comparisons
|
||||
require('mongodb-legacy').ObjectId.cacheHexString = true
|
||||
@@ -0,0 +1,29 @@
|
||||
import { vi } from 'vitest'
|
||||
import './common_bootstrap.js'
|
||||
import sinon from 'sinon'
|
||||
import logger from '@overleaf/logger'
|
||||
|
||||
vi.mock('@overleaf/logger', async () => {
|
||||
const sinon = (await import('sinon')).default
|
||||
return {
|
||||
default: {
|
||||
debug: sinon.stub(),
|
||||
info: sinon.stub(),
|
||||
log: sinon.stub(),
|
||||
warn: sinon.stub(),
|
||||
err: sinon.stub(),
|
||||
error: sinon.stub(),
|
||||
fatal: sinon.stub(),
|
||||
},
|
||||
}
|
||||
})
|
||||
|
||||
beforeEach(ctx => {
|
||||
ctx.logger = logger
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
vi.restoreAllMocks()
|
||||
vi.resetModules()
|
||||
sinon.restore()
|
||||
})
|
||||
Reference in New Issue
Block a user