Skip to content

Commit

Permalink
Add an ability to run specific test using describe
Browse files Browse the repository at this point in the history
Ref: #5
  • Loading branch information
projkov committed Sep 8, 2024
1 parent a6ddb66 commit 16b3540
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/modules/test_runs/testRun.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ export class TestRunController {
@Post()
@ApiOperation({ summary: 'Create a new test session' })
async create(@Res() res: Response, @Body() createTestSessionDto: InitiateTestRunDto) {
const { suiteId, sessionId } = createTestSessionDto;
const { suiteId, sessionId, testId } = createTestSessionDto;
const testRegex = `/src/suites/${suiteId}/.*\\.(test|spec)\\.[jt]sx?$`;
const optionsWithTest = testId ? { testNamePattern: testId } : {};

const options = {
...testOptions,
Expand All @@ -40,14 +41,15 @@ export class TestRunController {
SESSION_ID: sessionId,
}),
},
...optionsWithTest,
};

try {
const { results } = await runCLI(options as any, [process.cwd()]);
const currentSession = await this.sessionService.findOne(sessionId);
const testRun = await this.testRunService.create({
session: currentSession,
suiteId,
suiteId: testId ? testId : suiteId,
testResults: results,
});
res.status(200).json({ testRun });
Expand Down
7 changes: 7 additions & 0 deletions src/modules/test_runs/testRun.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,11 @@ export class InitiateTestRunDto {
type: String,
})
suiteId: string;

@ApiProperty({
example: 'Patients test Should only have available interactions',
description: 'Run specific test',
type: String,
})
testId: string;
}

0 comments on commit 16b3540

Please sign in to comment.