Skip to main content
Glama

create_test_script

Generate or update test scripts for Zephyr Scale Cloud test cases using Gherkin or plain text formats to define testing procedures.

Instructions

Create or update a test script for a test case (removes existing test steps)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
testCaseKeyYesTest case key (format: [A-Z]+-T[0-9]+)
textYesTest script content (Gherkin format for bdd type, plain text for plain type)
typeNoScript type (default: bdd)bdd

Implementation Reference

  • The main handler function for the 'create_test_script' tool. Validates input parameters (testCaseKey, text, optional type), prepares script data, calls the Zephyr client to create/update the test script, and returns a formatted success response or error.
    async function createTestScript(args) { try { const { testCaseKey, text, type } = args; if (!testCaseKey) { throw new Error('testCaseKey is required'); } if (!config.testCaseKeyPattern.test(testCaseKey)) { throw new Error('Invalid testCaseKey format. Must match pattern: [A-Z]+-T[0-9]+'); } if (!text) { throw new Error('text (script content) is required'); } if (typeof text !== 'string' || text.trim().length === 0) { throw new Error('text must be a non-empty string'); } const scriptData = { text: text.trim() }; // Optional type field (defaults to bdd/Gherkin if not specified) if (type) { if (typeof type !== 'string' || !['bdd', 'plain'].includes(type.toLowerCase())) { throw new Error('type must be either "bdd" (Gherkin) or "plain"'); } scriptData.type = type.toLowerCase(); } else { scriptData.type = 'bdd'; // Default to bdd } const result = await client.createTestScript(testCaseKey, scriptData); return { content: [ { type: 'text', text: JSON.stringify({ message: `Test script ${scriptData.type === 'bdd' ? 'created/updated' : 'created/updated'} successfully for ${testCaseKey}`, testCaseKey, scriptType: scriptData.type, result, warning: 'If this test case had existing test steps, they have been implicitly removed as test scripts and steps are mutually exclusive', note: scriptData.type === 'bdd' ? 'Script should be in Gherkin format (Given/When/Then/And/But)' : 'Plain text script format' }, null, 2) } ] }; } catch (error) { return { content: [ { type: 'text', text: formatError(error, `creating test script for ${args.testCaseKey}`) } ], isError: true }; }
  • Input schema for the 'create_test_script' tool, defining required testCaseKey (with pattern validation), required text (non-empty string), and optional type enum ['bdd', 'plain'].
    inputSchema: { type: 'object', properties: { testCaseKey: { type: 'string', description: 'Test case key (format: [A-Z]+-T[0-9]+)', pattern: config.testCaseKeyPattern.source }, text: { type: 'string', description: 'Test script content (Gherkin format for bdd type, plain text for plain type)', minLength: 1 }, type: { type: 'string', description: 'Script type (default: bdd)', enum: ['bdd', 'plain'], default: 'bdd' } }, required: ['testCaseKey', 'text'] },
  • Tool registration object defining name 'create_test_script', description, inputSchema, and reference to the handler function. This array is imported and spread into the main allTools list in src/index.js.
    { name: 'create_test_script', description: 'Create or update a test script for a test case (removes existing test steps)', inputSchema: { type: 'object', properties: { testCaseKey: { type: 'string', description: 'Test case key (format: [A-Z]+-T[0-9]+)', pattern: config.testCaseKeyPattern.source }, text: { type: 'string', description: 'Test script content (Gherkin format for bdd type, plain text for plain type)', minLength: 1 }, type: { type: 'string', description: 'Script type (default: bdd)', enum: ['bdd', 'plain'], default: 'bdd' } }, required: ['testCaseKey', 'text'] }, handler: createTestScript },
  • ZephyrClient helper method that performs the actual API POST request to create/update the test script for the given test case.
    async createTestScript(testCaseKey, scriptData) { return this.request('POST', `/testcases/${testCaseKey}/testscript`, scriptData); }

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/donyfs/mcp-zephyr'

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