/** * Jest 测试设置 */ // 增加测试超时时间 jest.setTimeout(30000) // 全局清理 afterAll(async () => { // 关闭所有数据库连接 const mongoose = require('mongoose') if (mongoose.connection.readyState !== 0) { await mongoose.connection.close() } }) // 抑制控制台日志(测试时) if (process.env.SUPPRESS_LOGS) { global.console = { ...console, log: jest.fn(), debug: jest.fn(), info: jest.fn(), warn: jest.fn(), error: jest.fn() } }