38 lines
825 B
JavaScript
38 lines
825 B
JavaScript
import http from 'k6/http';
|
|
import { check, sleep } from 'k6';
|
|
|
|
export const options = {
|
|
vus: 5,
|
|
duration: '3m',
|
|
thresholds: {
|
|
http_req_duration: ['p(95)<30000'], // Screenshots take longer
|
|
},
|
|
};
|
|
|
|
const API_URL = __ENV.API_URL || 'http://localhost:3000';
|
|
const API_KEY = __ENV.API_KEY || 'test-key';
|
|
|
|
export default function () {
|
|
const res = http.post(
|
|
`${API_URL}/api/screenshot`,
|
|
JSON.stringify({
|
|
url: 'https://example.com',
|
|
options: { fullPage: true }
|
|
}),
|
|
{
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
'x-api-key': API_KEY,
|
|
},
|
|
}
|
|
);
|
|
|
|
check(res, {
|
|
'status is 200': (r) => r.status === 200,
|
|
'response has success': (r) => r.json('success') === true,
|
|
'response has url': (r) => r.json('data.url') !== undefined,
|
|
});
|
|
|
|
sleep(2);
|
|
}
|