This is documentation for the next version of Grafana k6 documentation. For the latest stable release, go to the latest version.
Mock
You can use this secret source to test your tests quick and easy.
$ k6 run --secret-source=cli=mysecret=value script.js
$ docker run -it --rm \
-v <scriptdir>:/scripts \
grafana/k6 run --secret-source=mock=mysecret=value /scripts/script.js
You can even use multiple ones and have some of them named or set as default.
$ k6 run --secret-source=mock=default,cool="cool secret" --secret-source=mock=name=another,cool="not cool secret" multi-source.test.js```
import secrets from "k6/secrets";
export default async () => {
const my_secret = await secrets.get("cool");
console.log(my_secret == "cool secret");
const anothersource = await secrets.source("another")
console.log(await anothersource.get("cool") == "cool secret");
console.log(await anothersource.get("cool") == "not cool secret");
}