npm package: @newrelic/continuous-automated-testing
Description: CLI and library package for running New Relic Synthetic tests in CICD pipelines
Author: New Relic Synthetics Team
Latest version: 0.1.4

[![New Relic Experimental header](https://github.com/newrelic/open-source-office/raw/master/examples/categories/images/Experimental.png)](https://github.com/newrelic/open-source-office/blob/master/examples/categories/index.md#category-new-relic-experimental)

# continuous-automated-testing-ci
CLI and library that adds Synthetics Continuous Automated Testing directly into your CICD pipeline!

# Installation
To install the package for use as a library, use your favorite npm-based package manager:

`npm install @newrelic/continuous-automated-testing`

For use as a CLI package, install it globally:

`npm install @newrelic/continuous-automated-testing -g`

# Usage
### CLI

To run a batch of tests when using the package as a CLI, use the run-tests command:

```newrelic-cat run-tests -a <new-relic-api-key> -c <json-config-file-path -v```

The ```run-tests``` command will start a batch of tests based on the config file input.  The results will be displayed once the tests have finished running.

The command has the following options:
 - ```-a, --api-key <value>```: Your New Relic API key.  We suggest using a secrets manager during CI to avoid hardcoding and exposing your API key.
 - ```-c, --config-file-path <value>```: Relative path to a JSON CAT configuration file.  See an example [here](#configuration-file-example).
 - ```-v, --verbose```: See more detail on test results in STDOUT.  When not enabled, only blocking tests will have all details displayed. Can also be added in the [config file](#configuration-file-example).

 ### Library

 After [installing](#installation) the package, import the ```runTestBatch``` function:

 ```import { runTestBatch } from "@newrelic/newrelic-continuous-automated-testing"```

 The function takes the following parameters:

 - ```apiKey```: A New Relic API key.
 - ```config```: A JSON CAT configuration file.  See an example [here](#configuration-file-example).


## Configuration File Example
```
{
    "accountId": 12345,                     // Required
    "region": "US",                         // Required, options: US, EU
    "verbose": true,                        // Optional, default: false
    "tests": [                              // Array of tests to run
      {
        "monitorGuid": "monitor-GUID-1",    // Required
        "config": {                         // All config fields optional
          "isBlocking": true,
          "overrides":{
              "startingUrl": "example.com"
          }
        }
      },
      {
        "monitorGuid": "monitor-GUID-2"     // Required
      }
  ],
    "config": {                             // All config fields optional
        "batchName": "Test Batch"
    }
  }
  
```


## Support

New Relic hosts and moderates an online forum where customers can interact with New Relic employees as well as other customers to get help and share best practices. 

https://forum.newrelic.com/s/

## License
New Relic Continuous Automated Testing CLI is licensed under the [Apache 2.0](http://apache.org/licenses/LICENSE-2.0.txt) License.

The New Relic Continuous Automated Testing CLI also uses source code from third-party libraries. You can find full details on which libraries are used and the terms under which they are licensed in the [third-party notices document](https://github.com/newrelic-experimental/newrelic-continuous-automated-testing/blob/main/THIRD_PARTY_NOTICES.md).