Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Juandavi1/xk6-prompt
k6 extension that adds support for input arguments via UI
https://github.com/Juandavi1/xk6-prompt
go prompt terminal-ui xk6 xk6-extension
Last synced: about 2 months ago
JSON representation
k6 extension that adds support for input arguments via UI
- Host: GitHub
- URL: https://github.com/Juandavi1/xk6-prompt
- Owner: Juandavi1
- License: mit
- Created: 2022-11-17T18:17:54.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-06-10T08:27:21.000Z (6 months ago)
- Last Synced: 2024-07-30T21:05:35.360Z (4 months ago)
- Topics: go, prompt, terminal-ui, xk6, xk6-extension
- Language: Go
- Homepage:
- Size: 29.1 MB
- Stars: 14
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-k6 - xk6-prompt - Support for input arguments via UI. (Extensions / Community)
- awesome-k6 - xk6-prompt - Support for input arguments via UI. (Extensions / Community)
README
# xk6-prompt
[![Go](https://github.com/Juandavi1/xk6-prompt/actions/workflows/go.yml/badge.svg?branch=main)](https://github.com/Juandavi1/xk6-prompt/actions/workflows/go.yml)
![k6 version](https://img.shields.io/badge/K6-v0.47.0-7d64ff)
![xk6 version](https://img.shields.io/badge/Xk6-v0.9.2-7d64ff)
![xk6 version](https://img.shields.io/badge/Go-v1.19-79d4fd)![prompt_example](assets/prompt.svg)
_k6 extension that adds support for input arguments via UI._
#### Install
1. Install [xk6](https://github.com/grafana/xk6)
```console
go install go.k6.io/xk6/cmd/xk6@latest
```
2. Build the extension using:```console
xk6 build --with github.com/Juandavi1/xk6-prompt
```#### Import
```js
import prompt from 'bin/k6/x/prompt';
```#### Input select
```js
export default function () {
const options = ["smoke", "load"]
const selected = prompt.select("kind of test", ...options)
console.log(typeof selected === "string")
}
```#### Read string
```js
export default function () {
const inputString = prompt.readString("type a string")
console.log(typeof inputString === "string")
}
```#### Read int
```js
export default function () {
const inputNumber = prompt.readInt("Type a number")
console.log(typeof inputNumber === "number")
}
```#### Read float
```js
export default function () {
const inputNumber = prompt.readFloat("Type a float")
console.log(typeof inputNumber === "number")
}
```### Continuous Testing
If you are in a **continuous testing environment** you can pass the input arguments via environment variables.
Example:
####
```js
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:
```console
k6 run -e num=10 script.js
```### Manually building from source
Install Go tools [1.19](https://golang.org/doc/install)
Clone this repo
```console
git clone [email protected]:Juandavi1/xk6-prompt.git
```Install dependencies
```console
make install
```Build the extension binary
```console
make build
```Execute the example using the extension binary
```console
make run
```### Examples
You can find more examples in the [examples](examples) folder.
*#HavingFunLearning* 🦾