Hypertest v2 Docs
HyperTest
  • Overview
    • How It Works?
  • SETUP GUIDE
    • Installation
      • Deploy HyperTest Server
      • Creating your first User
      • Adding your first service
      • Integrate SDK
        • Node.js
          • Node.js SDK with CJS
          • Node.js SDK with ESM
        • Java
    • Start a Test Run
      • CLI Login
      • Type References
      • Java
  • Interpreting Test Results
    • Test Results
    • Understanding Results Categories
    • Mock Not Found
    • AI Match Mocks
    • Accepting Changes
  • USER GUIDES
    • Node.js SDK
      • Limit memory usage
      • Supported NPM packages
      • Mock Dependencies Manually
      • Unmocking/Passing Through
      • Sampling and blocking requests
      • Manage Global Variables
      • Mocking Environment Variables
      • Tags
      • Set HTTP path patterns
      • Discard a test case(Request) while recording
      • Set Git Commit Hash
      • Code coverage based features
        • Continuous Coverage
        • Updating test coverage
        • Running post test deduplication
        • Only testing modified requests
        • Ignore differences for unmodified requests
      • Experimental flags
      • Manual Request
      • Only testing modified requests
      • Server hooks
    • Java SDK
      • Sampling and blocking requests
      • Mock Dependencies Manually
      • Tags
      • Unmocking/Passing Through
      • Code Coverage Setup and Report Generation
      • Supported Java packages
    • Build your own Docker Image
    • CLI Config
    • Ignoring Differences
      • Type References for Filter functions
  • Impact Features
    • Fast Mode
    • Code Coverage Report
    • Delete Recorded Requests
    • Inter Service Testing
  • Release History
    • Slack Integration
    • Version History
Powered by GitBook
On this page
  • Prerequisites
  • 1. Install/update ht-cli npm package
  • Getting Started:
  • 1. Create a Test Configuration File
  • 2. CLI token generation
  • 3. Start new test
  • 4. Test reports
  1. SETUP GUIDE

Start a Test Run

Prerequisites

1. Install/update ht-cli npm package

npm install -g @hypertestco/ht-cli --save-exact

Verify htcli has been installed using the below command:

htcli --help

Getting Started:

1. Create a Test Configuration File

Available Configurations:

.htTestConf.js
const requestTypes = {
  HTTP: 'HTTP',
  GRAPHQL: 'GRAPHQL',
  KAFKA: 'KAFKA',
  GRPC: 'GRPC',
  AMQP: 'AMQP',
};

module.exports = {
  htBackendBaseUrl: "", // URL of HyperTest server (Required)
  serviceIdentifier: "", // UUID for the service (Required)
  requestTypesToTest: [requestTypes.HTTP], // What kind of requests to include in the test
  httpCandidateUrl: "", // HTTP URL of App under test (Optional)
  // graphqlCandidateUrl: "", // GraphQL URL of App under test (Optional)
  appStartCommand: process.platform === 'win32' ? 'npm.cmd' : 'npm', // Command to start the app (Required)
  appStartCommandArgs: ["<Argument 1>", "<Argument 2>"],  // App start command arguments (Required)
  appWorkingDirectory: __dirname, // Working directory for the app (default: current working dir) (Optional)
  appStartTimeoutSec: 30, // Timeout in seconds for the start command (default: 10) (Optional)
  showAppLogs: true, // Whether to show app logs (default: false) (Optional)
  shouldReportHeaderDiffs: false, // Whether to report differences in headers (default: false) (Optional)
  testBatchSize: 50, // Number of concurrent test requests (default: 50) (Optional)
  //testRequestsLimit": 10, // Number requests to test (Optional)
  //httpReqFiltersArr: [], // "<GET /users>", "<ANY REGEX:^/payments>" (Optional)
  htExtraHeaders: { // Object containing additional headers for HyperTest server requests (Optional)
    // authorization: 'Bearer xyz'
  },
  fastMode: true, // Default false. (aggregate requests only on the basis of request input and output schema - ignoring mock schemas)
  // httpReqsToTest: [], // specific http requests to be tested can be mentioned. Request Id can be taken from "All Requests" page in dashboard.
  // graphqlReqsToTest: [], // specific graphql requests to be tested can be mentioned.
  // grpcReqsToTest: [], // specific grpc requests to be tested can be mentioned.
  // kafkaReqsToTest: [], // specific kafka requests to be tested can be mentioned.
  // amqpReqsToTest: [], // specific amqp requests to be tested can be mentioned.
  // tags: [{name: '', value: ''}], // requests which contain the mentioned tags will be tested. Refer Tags under "User Guides/Node.js SDK" for more information.
  // shouldIgnoreErrStackTraceDiffs: true, // Stack trace differences are ignored in errors.(default: true) (Optional)
  
  // filterFunctionToIgnoreMockDiffs:({ mockDiff, currentMock, requestObj }) => { 
  //  // if false is returned then the diff will be ignored
  //  if(mockDiff?.originalValue?.langType === 'Date') return false;
  //  if(mockDiff?.evaluatedPath?.at(-1) === "url" || mockDiff?.evaluatedPath?.at(-2) === "headers") return false;
  //  if(mockDiff?.evaluatedPath?.at(-1) === "host") return false;
  //  return true;
  //},
  
  // filterFunctionToIgnoreResponseDiffs: ({ responseDiff, requestObj }) => { // Param Types are mentioned in Type References page
  // // if false is returned then the response difference will be ignored  
  //  if(responseDiff?.evaluatedPath?.at(-1) === "url" || evaluatedPath?.evaluatedPath?.at(-2) === "headers") return false;
  //  if(responseDiff?.evaluatedPath?.at(-1) === "host") return false;
  //  return true;
  //},
  // exitCodeSetter({ testResult }) {
  //  console.log('==test results==')
  //  console.log(testResult)
  //  return 0;
  //},
  // initialTimestamp: "", // Initial timestamp in ISO format (Optional)
  // finalTimestamp: "", // Final timestamp in ISO format (Optional)
  // cliServerHost: "", // HT CLI server Host to be Used by Clients(server ignores this) (default: localhost) (Optional)
  // sdkServerHost: "", // HT SDK server Host to be Used by Clients(server ignores this) (default: localhost) (Optional)
  // autoAcceptChangesInCaseOnlyNoiseDetected: false,
  // shouldIgnoreErrStackTraceDiffs: true,
  // exclusionStringsForDifferences: [], // e.g., ['01\.02\.03\.04', 'HyPeRtEsT'],
  // reservedAppPorts: [], // Ports used by the host application e.g., [3001,4001]
};

2. CLI token generation

Please follow the link given below to complete token generation if test is being run in CI env.

3. Start new test

Start a new test by running this command.

htcli start-new-test --config-file-path ./.htTestConf.js

Open the help to list all possible options available

htcli start-new-test --help

4. Test reports

After the test is completed. You can see the results on the dashboard under Test Results

PreviousJavaNextCLI Login

Last updated 1 month ago

Please complete login for CLI token generation when prompted by cli during test progress on local. For more information click .

CLI Login
here