Migrate to vitest from jest (#1074)

Co-authored-by: Felix Weinberger <3823880+felixweinberger@users.noreply.github.com>
Co-authored-by: Felix Weinberger <fweinberger@anthropic.com>
This commit is contained in:
Matt 2025-11-14 14:08:00 +00:00 • committed by GitHub
commit 98df118a4c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -203,7 +203,7 @@ describe('ResourceTemplate', () => {
* Test: ResourceTemplate with List Callback
*/
test('should create ResourceTemplate with list callback', async () => {
const list = jest.fn().mockResolvedValue({
const list = vi.fn().mockResolvedValue({
resources: [{ name: 'Test', uri: 'test://example' }]
});
@ -228,7 +228,7 @@ describe('ResourceTemplate', () => {
describe('tool()', () => {
afterEach(() => {
jest.restoreAllMocks();
vi.restoreAllMocks();
});
/***
@ -1705,7 +1705,7 @@ describe('tool()', () => {
});
// Spy on console.warn to verify warnings are logged
const warnSpy = jest.spyOn(console, 'warn').mockImplementation();
const warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {});
// Test valid tool names
testServer.registerTool(
@ -4067,15 +4067,15 @@ describe('Tool title precedence', () => {
});
describe('elicitInput()', () => {
const checkAvailability = jest.fn().mockResolvedValue(false);
const findAlternatives = jest.fn().mockResolvedValue([]);
const makeBooking = jest.fn().mockResolvedValue('BOOKING-123');
const checkAvailability = vi.fn().mockResolvedValue(false);
const findAlternatives = vi.fn().mockResolvedValue([]);
const makeBooking = vi.fn().mockResolvedValue('BOOKING-123');
let mcpServer: McpServer;
let client: Client;
beforeEach(() => {
jest.clearAllMocks();
vi.clearAllMocks();
// Create server with restaurant booking tool
mcpServer = new McpServer({