github.com/kubeshop/testkube@v1.17.23/test/cli-tests/tests/create-test.js (about)

     1  import {execSync} from 'node:child_process'
     2  import { expect } from 'chai';
     3  
     4  import ApiHelpers from '../helpers/api-helpers';
     5  const apiHelpers=new ApiHelpers(process.env.API_URL);
     6  import TestDataHandler from '../helpers/test-data-handlers';
     7  const testDataHandler=new TestDataHandler();
     8  import OutputValidators from '../helpers/output-validators';
     9  const outputValidators=new OutputValidators();
    10  
    11  async function createTestFlow(testName) {
    12      const testData = testDataHandler.getTest(testName)
    13  
    14      //prerequisites
    15      await apiHelpers.assureTestNotCreated(testData.name)
    16  
    17      //command
    18      const rawOutput = execSync(`testkube create test --name ${testData.name} --type ${testData.type} --test-content-type ${testData.content.type} --git-uri ${testData.content.repository.uri} --git-branch ${testData.content.repository.branch} --git-path ${testData.content.repository.path} --label core-tests=${testData.labels['core-tests']}`); //TODO: command builder
    19      const output = rawOutput.toString()
    20      const cleanOutput = outputValidators.removeAnsiCodes(output)
    21  
    22      //validate command output
    23      outputValidators.validateTestCreated(testData.name, cleanOutput)
    24  
    25      //validate result
    26      const isTestCreated = await apiHelpers.isTestCreated(testData.name)
    27  
    28      expect(isTestCreated).to.be.true;
    29  }
    30  
    31  describe('Create test with CLI', function () {
    32      it('Create Cypress test with git-dir', async function () {
    33          const testName = 'cypress-git-dir'
    34          
    35          await createTestFlow(testName)
    36      });
    37      it('Create K6 test with git-file', async function () {
    38          const testName = 'k6-git-file'
    39          
    40          await createTestFlow(testName)
    41      });
    42      it('Create Postman test with git-file', async function () {
    43          const testName = 'postman-git-file'
    44          
    45          await createTestFlow(testName)
    46      });
    47  });