Last active
June 14, 2023 22:09
-
-
Save akoskovacs/5796559e9a7c2fa620e369efa8c3370a to your computer and use it in GitHub Desktop.
k6 API testing Lucky Framwork template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import http from 'k6/http'; | |
import { check, group } from 'k6'; | |
export let options = { | |
stages: [ | |
{ duration: '0.5m', target: 3 }, // simulate ramp-up of traffic from 1 to 3 virtual users over 0.5 minutes. | |
{ duration: '0.5m', target: 4}, // stay at 4 virtual users for 0.5 minutes | |
{ duration: '0.5m', target: 0 }, // ramp-down to 0 users | |
], | |
}; | |
const URL = 'http://localhost:3000'; | |
export default function () { | |
group('API Login', () => { | |
const headers = { 'Content-Type': 'application/json' }; | |
const data = { | |
"user": { | |
"email": "[email protected]", | |
"password": "testing" | |
}, | |
}; | |
const response = http.post(`${URL}/api/sign_ins`, JSON.stringify(data), { headers: headers }); | |
check(response, { | |
"status code should be 200": res => res.status === 200, | |
}); | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment