Updating test coverage

How to update test coverage ?

Make sure you go through the steps to add nyc to your project here before this.

Hypertest allows you to update coverage of the tests that have so far been recorded. This is run using a cli command. Running this will spawn your application instance, hit all the test cases recorded so far and store the code coverage generated.

Make sure that you checkout to your master (Or the branch that is your baseline for recording requests) and have no local changes before you run this command. We want to store the lines covered on master.

  1. Create ht cli config file. This is the same that is used to run cli test.

  2. Your app will be spawned using the command you give in the cli config. Make sure you run your app using nyc in that command. (Don't run the cli process with nyc, just your app)

Example

// App's package.json
{
    "scripts" : {
        "start-app-wth-nyc" : "nyc --nycrc-path <nyc-config-file> <your app start command>"
    }, 
}
  1. Change the appStartCommand and appStartCommandArgs ( inside your cli config ) to the what you created in step 2.

Example:

{
  /*
    Rest of your cli config...
  */
  appStartCommand: 'npm',
  appStartCommandArgs: ['run', 'start-app-with-nyc'],
}
  1. Please complete the CLI token generation as mentioned here.

  2. Run the cli command to update coverage

htcli update-coverage --config-file-path <path-to-your-cli-config>

Last updated