fintech-automation-test
Version:
Autonomous Test Automation
61 lines (52 loc) • 2.08 kB
JavaScript
const http = require('k6/http');
const { check, sleep } = require('k6');
const testData = JSON.parse(open('../../../test/api/testData/api_test_data.json'));
const options = {
vus: 10, // Virtual users
duration: '1m', // Test duration
};
// Function to perform login and return the session token or cookie
// function login() {
// const url = config.swaggerUrl; // Login endpoint
// const payload = JSON.stringify({
// username: config.username,
// password: config.password,
// });
// const params = {
// headers: {
// 'Content-Type': 'application/json',
// },
// };
// const response = http.post(url, payload, params);
//
// check(response, {
// 'login was successful': (r) => r.status === 200,
// });
//
// // Extract token from response body
// const authToken = JSON.parse(response.body).token; // Example: Extract token from response body
// return authToken; // Return the token to be used in subsequent requests
// }
function defaultFunction() {
//const token = login();
const headers = {
// 'Authorization': `Bearer ${token}`, // Pass the token as a Bearer token
'Content-Type': 'application/json',
};
let petPetidResponse = http.del('https://petstore.swagger.io/v2/pet/{petId}', { headers });
check(petPetidResponse, {
'DELETE /pet/{petId} status is 200': (r) => r.status === 200,
});
sleep(1);
let storeOrderOrderidResponse = http.del('https://petstore.swagger.io/v2/store/order/{orderId}', { headers });
check(storeOrderOrderidResponse, {
'DELETE /store/order/{orderId} status is 200': (r) => r.status === 200,
});
sleep(1);
let userUsernameResponse = http.del('https://petstore.swagger.io/v2/user/{username}', { headers });
check(userUsernameResponse, {
'DELETE /user/{username} status is 200': (r) => r.status === 200,
});
sleep(1);
}
module.exports = { options, default: defaultFunction };