diff --git a/src/codegen/codegen.test.ts b/src/codegen/codegen.test.ts index f8338865..ab71b6a2 100644 --- a/src/codegen/codegen.test.ts +++ b/src/codegen/codegen.test.ts @@ -3,6 +3,7 @@ import { generateScript, generateRequestSnippets, generateVariableDeclarations, + generateGroupSnippet, } from './codegen' import { CorrelationStateMap, TestRule } from '@/types/rules' import { generateSequentialInt } from '@/rules/utils' @@ -193,4 +194,23 @@ describe('Code generation', () => { ).toBe(expectedResult.replace(/\s/g, '')) }) }) + + describe('generateGroupSnippet', () => { + it('should generate group snippet', () => { + const expectedResult = ` + group('group_1', function(){}); + sleep(1) + ` + + expect( + generateGroupSnippet('group_1', '', { + sleepType: 'groups', + timing: { + type: 'fixed', + value: 1, + }, + }).replace(/\s/g, '') + ).toBe(expectedResult.replace(/\s/g, '')) + }) + }) }) diff --git a/src/codegen/codegen.ts b/src/codegen/codegen.ts index 52ecd348..05f1a118 100644 --- a/src/codegen/codegen.ts +++ b/src/codegen/codegen.ts @@ -102,8 +102,8 @@ export function generateGroupSnippet( ): string { return `group('${groupName}', function() { ${requestSnippets} - ${thinkTime.sleepType === 'groups' ? `${generateSleep(thinkTime.timing)}` : ''} - });` + }); + ${thinkTime.sleepType === 'groups' ? `${generateSleep(thinkTime.timing)}` : ''}` } export function generateSingleRequestSnippet( @@ -128,7 +128,6 @@ export function generateSingleRequestSnippet( console.error('Failed to serialize request content', error) } - console.log(request) const params = `params = ${generateRequestParams(request)}` const main = `