Skip to content

A k6 extension that loads env vars from a .env file.

License

Notifications You must be signed in to change notification settings

tmulkern/xk6-dotenv

 
 

Repository files navigation

xk6-dotenv

A k6 extension that loads env vars from a .env file.

This extension follow the convention for managing multiple environments (i.e. development, test, production). The actual environment name came from an env variable named K6_ENV. Setting this to false value disable the convention mentoined above and no .env file will be loaded automatically.

Hierarchy Priority Filename K6_ENV Should I .gitignoreit? Notes
1st (highest) .env.development.local development Yes! Local overrides of environment-specific settings.
1st .env.test.local test Yes! Local overrides of environment-specific settings.
1st .env.production.local production Yes! Local overrides of environment-specific settings.
2nd .env.local (any expect false) Definitely. Local overrides. This file is loaded for all environments except test.
3rd .env.development development No. Shared environment-specific settings
3rd .env.test test No. Shared environment-specific settings
3rd .env.production production No. Shared environment-specific settings
Last .env (any expect false) Depends The Original

The underlying implementation is https://github.com/joho/godotenv

Built for k6 using xk6.

Usage

Import an entire module's contents:

import * as dotenv from "k6/x/dotenv";

Import a single export from a module:

import { parse } from "k6/x/dotenv";

API

This extension can be used as a library:

For complete API documentation click here!

Build

To build a k6 binary with this extension, first ensure you have the prerequisites:

Then:

  1. Install xk6:
$ go install go.k6.io/xk6/cmd/xk6@latest
  1. Build the binary:
$ xk6 build --with github.com/szkiba/xk6-dotenv@latest

About

A k6 extension that loads env vars from a .env file.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 62.6%
  • Go 37.4%