Skip to main content
Glama
Derrbal
by Derrbal
getCase.test.ts1.23 kB
import { afterEach, beforeEach, describe, expect, it } from 'vitest'; import nock from 'nock'; import { getCase } from '../src/services/testrailService'; import { config } from '../src/config'; describe('testrailService.getCase', () => { const baseApi = `${config.TESTRAIL_URL}`; const apiPath = '/index.php?/api/v2'; beforeEach(() => { nock.disableNetConnect(); }); afterEach(() => { nock.cleanAll(); nock.enableNetConnect(); }); it('returns normalized case', async () => { const caseId = 123; const scope = nock(baseApi) .get(`${apiPath}/get_case/${caseId}`) .reply(200, { id: caseId, title: 'Sample', section_id: 1, custom_field: 'x', }); const result = await getCase(caseId); expect(result).toEqual( expect.objectContaining({ id: caseId, title: 'Sample', section_id: 1, custom: { custom_field: 'x' } }), ); scope.done(); }); it('throws on 404', async () => { const caseId = 9999; const scope = nock(baseApi) .get(`${apiPath}/get_case/${caseId}`) .reply(404, { error: 'not found' }); await expect(getCase(caseId)).rejects.toMatchObject({ type: 'not_found' }); scope.done(); }); });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Derrbal/testrail-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server