This repo contains various opinionated starter templates for k6 projects.
Common across all templates is the use of folders and multiple JavaScript files to encourage code organization:
common
: A suitable location for storing re-usable functionsconfig
: Contains a JSON file that is used to populate the options object at runtime (allowing the separation of test config from code)scenarios
: A folder for storing scripts representing end-to-end scenariosscripts
: A folder for storing code that performs the actual automation
This template uses built-in k6 APIs and therefore requires no external dependencies. Use this template if you prefer to use the built-in APIs over those provided by the other templates.
This template uses the Httpx library to perform requests instead of the built-in k6/http module. Httpx caters for setting:
- a base URL for all requests so that it can easily be changed (e.g. when testing different environments)
- global request headers
- a global request timeout
The template also includes an example re-usable function for performing response validation called verifyResponse
.
This template uses the ChaiJS library through k6chaijs to perform assertions instead of using the built-in group and check functions.