# Getting Started

## Prerequisites

The asserted CLI requires at least Node v10. Check which version of Node you have installed with:

```bash
node -v
```

If you do not have Node installed, or have the wrong version, we recommend installing Node using one of the following:

* Mac / Linux - [nvm](https://github.com/nvm-sh/nvm)
* Windows - [nvm-windows](https://github.com/coreybutler/nvm-windows)

## Installation

{% hint style="info" %}
GitHub: <https://github.com/assertedio/asrtd>

NPM: <https://www.npmjs.com/package/asrtd>
{% endhint %}

Use NPM to globally install the asserted CLI:

```
npm i -g asrtd
```

At any time you can run the following to get a full breakdown of all CLI commands:

```bash
asrtd --help
```

Login to the CLI with:

```bash
asrtd login
```

This will open a browser to [Token Management](https://app.asserted.io/tokens) so you can create a token and paste it into the interactive prompt. Tokens are associated with the user, not the project, and take on all of the abilities of that user.

## Initialize Routine

Usually routines are associated with a specific git repo or project. Move to the directory where you want to create the test files associated with a routine.

```bash
cd my-project-repo/
```

Run the following command to create a `.asserted` directory with all the necessary asserted dependencies and configuration:

```bash
astrd init
```

Inside `.asserted`, you'll find:

```bash
routine.json    ## Routine configuration with interval and mocha config
package.json    ## NPM package defining the (currently) fixed set of dependencies available during testing
examples/       ## Directory containing examples, can be modified or removed  
```

Your routine is now configured, but only contains examples. To get an idea of how everything works, lets push the current version with the examples.

```bash
asrtd push
```

This will push the current version of the code to [asserted.io](https://app.asserted.io) and you should start seeing results in the dashboard within a few seconds.

## Downtime Notifications

Once you have a routine running, you'll want to know if it detects any errors.

Go to the settings page of that routine within [asserted.io](https://app.asserted.io) to add a notification configuration.&#x20;

You can be notified by email or Slack webhook, or by phone if you have a paid plan or have purchased extra SMS.

{% hint style="warning" %}
Any routines that do not have notifications configured are disabled 48 hours they are created. You can re-enable them at any time.

You'll receive an email before this happens, but there is no point in running a routine continuously that doesn't have any way of notifying someone of downtime.
{% endhint %}

## Development

From here on out, it works mostly like writing any other Mocha test. The free plans only have a fixed set of dependencies, but the paid plans can include any dependencies you wish. Check out [Dependencies](https://docs.asserted.io/reference/included-dependencies) for more on that.

You can create whatever tests or files you'd like inside the `.asserted` directory and they'll be included in the next push.&#x20;

By default, Mocha will run any files with the `.asrtd.js` suffix as tests. Though this can be configured inside the `routine.json` file.

### Running Locally

To run tests locally, you can use:

```bash
asrtd run
```

The results will look something like:

![Local run result](https://594756571-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M8DFhwh44DGXoIZuWQM%2F-M8DFxjtpkW-V7s3h9CN%2F-M8DPk_B1dzdFtQ5EOMt%2Flocal.png?alt=media\&token=6237040e-4abe-41ab-828d-993a5a37fdc7)

### Running Online

In the event that you have an issue that only seems to manifest when run online, you can use the following option to run the test inside [asserted.io](https://app.asserted.io):

```bash
asrtd run --online
```

{% hint style="info" %}
Online runs are rate-limited to prevent abuse, and should only be used to debug issues.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.asserted.io/master.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
