# k6

A set of k6 load tests that are run against real deployments.

## Prerequisites

- Install `k6` by following the [instructions](https://k6.io/docs/get-started/installation/)
- Create a `.env` file based on the `.env.shadow` template

## Dev

Runs the tests in dev mode with a single iteration and outputs the results to stdout only

```
yarn test:k6:dev subscribeToPrerelease
```

## Run

Runs the tests with a realistic load testing scenario, streams the results to [DataDog](https://app.datadoghq.com/dashboard/732-u2p-t8t/songwhip-load-tests) and generates a HTML summary.

```
yarn test:k6 subscribeToPrerelease stress
```

NOTE: In order to run this command on your local machine you need to have `docker` installed and you need to set the `DD_API_KEY` in the `.env` file.

## Github Action

The tests can also be run from a Github Action through the [Run k6 test](https://github.com/theorchard/songwhip-web/actions/workflows/runK6Test.yml) workflow.

You'll have to provide the `testData` as a stringified JSON payload. You can find a template of the data to provide for each test inside the `testData.js` file of the corresponding test.
