k6 extension that adds support for input arguments via UI.
- Install xk6
go install go.k6.io/xk6/cmd/xk6@latest
- Build the extension using:
xk6 build --with github.com/Juandavi1/xk6-prompt
import prompt from 'bin/k6/x/prompt';
export default function () {
const options = ["smoke", "load"]
const selected = prompt.select("kind of test", ...options)
console.log(typeof selected === "string")
}
export default function () {
const inputString = prompt.readString("type a string")
console.log(typeof inputString === "string")
}
export default function () {
const inputNumber = prompt.readInt("Type a number")
console.log(typeof inputNumber === "number")
}
export default function () {
const inputNumber = prompt.readFloat("Type a float")
console.log(typeof inputNumber === "number")
}
If you are in a continuous testing environment you can pass the input arguments via environment variables.
Example:
export default function () {
const myNumber = __ENV.num ? __ENV.num : prompt.readInt("enter a number")
console.log(typeof myNumber === "number")
}
And run the test with the environment variable:
k6 run -e num=10 script.js
Install Go tools 1.19
Clone this repo
git clone [email protected]:Juandavi1/xk6-prompt.git
Install dependencies
make install
Build the extension binary
make build
Execute the example using the extension binary
make run
You can find more examples in the examples folder.
#HavingFunLearning 🦾