Skip to content

Instantly share code, notes, and snippets.

@akoskovacs
Last active June 14, 2023 22:09
Show Gist options
  • Save akoskovacs/5796559e9a7c2fa620e369efa8c3370a to your computer and use it in GitHub Desktop.
Save akoskovacs/5796559e9a7c2fa620e369efa8c3370a to your computer and use it in GitHub Desktop.
k6 API testing Lucky Framwork template
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": "api@testing.com",
"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